Describe the bug
When creating a scheduled task from a local file (no github context) the CLI expects either --commit-trigger-enabled false
or --pull-request-trigger-enabled false
to be passed to skip the github token requirement.
Even when these are passed the context validation for the FileTask is broken, where the task cannot be created because the validation does not recognize the task type correctly.
The example from az acr task create
is broken:
cat task.yaml | az acr task create -n hello-world -r myregistry -f - -c /dev/null --schedule "0 */1 * * *"
Issue seems to be from how the context_path is validated and overwritten in certain conditions, as well as the default values for the command paramenters.
https://github.com/Azure/azure-cli/blob/2c3574179ea55cdb50fcbf61aea1c3402bdc16d6/src/azure-cli/azure/cli/command_modules/acr/task.py#L118
Related command
az acr task create
Errors
cli.azure.cli.core.azclierror: (ContextUndefined) Cannot determine the build context for the step of the task 'scheduledmanualtask'. Either the context should be a well formed absolute URI or there should be only one source trigger for the task.
Code: ContextUndefined
Message: Cannot determine the build context for the step of the task 'scheduledmanualtask'. Either the context should be a well formed absolute URI or there should be only one source trigger for the task.
Target: request
Issue script & Debug output
az acr task create -n scheduledmanualtask -r -f basicscheduletask.yaml -c /dev/null --schedule "0 /1 * * " --debug --subscription **** --commit-trigger-enabled false --pull-request-trigger-enabled false
cli.knack.cli: Command arguments: ['acr', 'task', 'create', '-n', 'scheduledmanualtask', '-r', '', '-f', 'basicscheduletask.yaml', '-c', 'nul', '--schedule', '0 /1 * * ', '--debug', '--subscription', ', '--commit-trigger-enabled', 'false', '--pull-request-trigger-enabled', 'false']
cli.knack.cli: init debug log:
Enable color in terminal.
cli.knack.cli: Event: Cli.PreExecute []
cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x01A82AC8>, <function OutputProducer.on_global_arguments at 0x01DA8BB8>, <function CLIQuery.on_global_arguments at 0x01DCD988>]
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate []
cli.azure.cli.core: Modules found from index for 'acr': ['azure.cli.command_modules.acr', 'azext_acrcssc']
cli.azure.cli.core: Loading command modules:
cli.azure.cli.core: Name Load Time Groups Commands
cli.azure.cli.core: acr 0.201 36 149
cli.azure.cli.core: Total (1) 0.201 36 149
cli.azure.cli.core: These extensions are not installed and will be skipped: ['azext_ai_examples', 'azext_next']
cli.azure.cli.core: Loading extensions:
cli.azure.cli.core: Name Load Time Groups Commands Directory
cli.azure.cli.core: acrcssc 0.028 3 4 C:\git\azure-cli-extensions\src\acrcssc
cli.azure.cli.core: Total (1) 0.028 3 4
cli.azure.cli.core: Loaded 38 groups, 153 commands.
cli.azure.cli.core: Found a match in the command table.
cli.azure.cli.core: Raw command : acr task create
cli.azure.cli.core: Command table: acr task create
cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x03FB8848>]
cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users<user>.azure\commands\2024-05-09.11-48-20.acr_task_create.28780.log'.
az_command_data_logger: command args: acr task create -n {} -r {} -f {} -c {} --schedule {} --debug --subscription {} --commit-trigger-enabled {} --pull-request-trigger-enabled {}
cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x03FE0988>]
cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad []
cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x04016C58>, <function register_cache_arguments..add_cache_arguments at 0x04016C08>]
cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded []
cli.knack.cli: Event: CommandInvoker.OnPreParseArgs []
cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x01DA8C08>, <function CLIQuery.handle_query_parameter at 0x01DCD9D8>, <function register_ids_argument..parse_ids_arguments at 0x04016CA8>]
cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ContainerRegistryManagementClient
cli.azure.cli.core.auth.persistence: build_persistence: location='C:\Users\\.azure\msal_token_cache.bin', encrypt=True
cli.azure.cli.core.auth.binary_cache: load: C:\Users<user>.azure\msal_http_cache.bin
urllib3.util.retry: Converted retries value: 1 -> Retry(total=1, connect=None, read=None, redirect=None, status=None)
... cut for brevity
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 2e540501-ab0d-4c92-aa5d-b1262c81da2a
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions/****/resourceGroups//providers/Microsoft.ContainerRegistry/registries/?api-version=2023-11-01-preview'
cli.azure.cli.core.sdk.policies: Request method: 'GET'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'b4a64780-0e34-11ef-89ba-0022487746b7'
cli.azure.cli.core.sdk.policies: 'CommandName': 'acr task create'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-n -r -f -c --schedule --debug --subscription --commit-trigger-enabled --pull-request-trigger-enabled'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.59.0 (MSI) azsdk-python-core/1.28.0 Python/3.11.8 (Windows-10-10.0.22631-SP0)'
cli.azure.cli.core.sdk.policies: 'Authorization': ''
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: This request has no body
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions//resourceGroups//providers/Microsoft.ContainerRegistry/registries/?api-version=2023-11-01-preview HTTP/1.1" 200 1232
cli.azure.cli.core.sdk.policies: Response status: 200
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '1232'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'api-supported-versions': '2023-11-01-preview'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-reads': '11999'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '001d0e0f-68c3-4310-9fb3-3756f1b48fbd'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': '001d0e0f-68c3-4310-9fb3-3756f1b48fbd'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTUS2:20240509T184822Z:001d0e0f-68c3-4310-9fb3-3756f1b48fbd'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: CE44F26B34734C3183FBA0E3B174333D Ref B: CO6AA3150217019 Ref C: 2024-05-09T18:48:22Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Thu, 09 May 2024 18:48:21 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"sku":{"name":"Premium","tier":"Premium"},"type":"Microsoft.ContainerRegistry/registries","id":"/subscriptions//resourceGroups//providers/Microsoft.ContainerRegistry/registries/","name":"","location":"eastus","tags":{},"systemData":{"lastModifiedBy":"@","lastModifiedByType":"User","lastModifiedAt":"2024-03-27T18:51:51.6889743+00:00"},"properties":{"loginServer":".azurecr.io","creationDate":"2020-04-15T18:50:32.0275927Z","provisioningState":"Succeeded","adminUserEnabled":true,"networkRuleSet":{"defaultAction":"Allow","ipRules":[]},"policies":{"quarantinePolicy":{"status":"disabled"},"trustPolicy":{"type":"Notary","status":"disabled"},"retentionPolicy":{"days":0,"lastUpdatedTime":"2024-03-27T18:51:51.8013798+00:00","status":"disabled"},"exportPolicy":{"status":"enabled"},"azureADAuthenticationAsArmPolicy":{"status":"enabled"},"softDeletePolicy":{"retentionDays":7,"status":"disabled"}},"encryption":{"status":"disabled"},"dataEndpointEnabled":false,"dataEndpointHostNames":[],"privateEndpointConnections":[],"publicNetworkAccess":"Enabled","networkRuleBypassOptions":"AzureServices","zoneRedundancy":"Disabled","metadataSearch":"Enabled"}}
cli.azure.cli.core.auth.credential_adaptor: CredentialAdaptor.get_token: scopes=('https://management.core.windows.net//.default',), kwargs={}
cli.azure.cli.core.auth.msal_authentication: UserCredential.get_token: scopes=('https://management.core.windows.net//.default',), claims=None, kwargs={}
msal.application: Cache hit an AT
msal.telemetry: Generate or reuse correlation_id: 252106aa-06d2-40af-848d-af9557c54691
cli.azure.cli.core.sdk.policies: Request URL: 'https://management.azure.com/subscriptions//resourceGroups//providers/Microsoft.ContainerRegistry/registries//tasks/scheduledmanualtask?api-version=2019-06-01-preview'
cli.azure.cli.core.sdk.policies: Request method: 'PUT'
cli.azure.cli.core.sdk.policies: Request headers:
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json'
cli.azure.cli.core.sdk.policies: 'Content-Length': '566'
cli.azure.cli.core.sdk.policies: 'Accept': 'application/json'
cli.azure.cli.core.sdk.policies: 'x-ms-client-request-id': 'b4a64780-0e34-11ef-89ba-0022487746b7'
cli.azure.cli.core.sdk.policies: 'CommandName': 'acr task create'
cli.azure.cli.core.sdk.policies: 'ParameterSetName': '-n -r -f -c --schedule --debug --subscription --commit-trigger-enabled --pull-request-trigger-enabled'
cli.azure.cli.core.sdk.policies: 'User-Agent': 'AZURECLI/2.59.0 (MSI) azsdk-python-core/1.28.0 Python/3.11.8 (Windows-10-10.0.22631-SP0)'
cli.azure.cli.core.sdk.policies: 'Authorization': ''
cli.azure.cli.core.sdk.policies: Request body:
cli.azure.cli.core.sdk.policies: {"location": "eastus", "properties": {"status": "Enabled", "platform": {"os": "linux", "architecture": "amd64"}, "agentConfiguration": {"cpu": 2}, "timeout": 3600, "step": {"type": "FileTask", "contextPath": "nul", "taskFilePath": "basicscheduletask.yaml", "values": []}, "trigger": {"timerTriggers": [{"schedule": "0 */1 * * *", "status": "Enabled", "name": "t1"}], "baseImageTrigger": {"baseImageTriggerType": "Runtime", "updateTriggerPayloadType": "Default", "status": "Enabled", "name": "defaultBaseimageTriggerName"}}, "credentials": {}, "isSystemTask": false}}
urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool: https://management.azure.com:443 "PUT /subscriptions//resourceGroups/*****/providers/Microsoft.ContainerRegistry/registries//tasks/scheduledmanualtask?api-version=2019-06-01-preview HTTP/1.1" 400 264
cli.azure.cli.core.sdk.policies: Response status: 400
cli.azure.cli.core.sdk.policies: Response headers:
cli.azure.cli.core.sdk.policies: 'Cache-Control': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Pragma': 'no-cache'
cli.azure.cli.core.sdk.policies: 'Content-Length': '264'
cli.azure.cli.core.sdk.policies: 'Content-Type': 'application/json; charset=utf-8'
cli.azure.cli.core.sdk.policies: 'Expires': '-1'
cli.azure.cli.core.sdk.policies: 'x-ms-ratelimit-remaining-subscription-writes': '1199'
cli.azure.cli.core.sdk.policies: 'x-ms-request-id': '6a48fbb4-1d6e-4358-a9ac-d9a42fb5fbcf'
cli.azure.cli.core.sdk.policies: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains'
cli.azure.cli.core.sdk.policies: 'X-Content-Type-Options': 'nosniff'
cli.azure.cli.core.sdk.policies: 'x-ms-correlation-request-id': 'a69289e7-6025-45a5-8bdd-a7e0809aaa78'
cli.azure.cli.core.sdk.policies: 'x-ms-routing-request-id': 'WESTUS2:20240509T184824Z:a69289e7-6025-45a5-8bdd-a7e0809aaa78'
cli.azure.cli.core.sdk.policies: 'X-Cache': 'CONFIG_NOCACHE'
cli.azure.cli.core.sdk.policies: 'X-MSEdge-Ref': 'Ref A: DCA36833D08D4148A92DF7837EAEC844 Ref B: CO6AA3150220053 Ref C: 2024-05-09T18:48:22Z'
cli.azure.cli.core.sdk.policies: 'Date': 'Thu, 09 May 2024 18:48:23 GMT'
cli.azure.cli.core.sdk.policies: Response content:
cli.azure.cli.core.sdk.policies: {"error":{"code":"ContextUndefined","message":"Cannot determine the build context for the step of the task 'scheduledmanualtask'. Either the context should be a well formed absolute URI or there should be only one source trigger for the task.","target":"request"}}
cli.azure.cli.core.azclierror: Traceback (most recent call last):
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 233, in invoke
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 664, in execute
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 731, in _run_jobs_serially
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 701, in _run_job
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 334, in call
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/acr/task.py", line 239, in acr_task_create
File "D:\a_work\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/mgmt/containerregistry/v2019_06_01_preview/operations/_tasks_operations.py", line 501, in _create_initial
azure.core.exceptions.HttpResponseError: (ContextUndefined) Cannot determine the build context for the step of the task 'scheduledmanualtask'. Either the context should be a well formed absolute URI or there should be only one source trigger for the task.
Code: ContextUndefined
Message: Cannot determine the build context for the step of the task 'scheduledmanualtask'. Either the context should be a well formed absolute URI or there should be only one source trigger for the task.
Target: request
Expected behavior
create a scheduled task from a yaml (file task) with no github context
not having to pass --commit-trigger-enabled false
or --pull-request-trigger-enabled false
to skip the github token validation
Environment Summary
azure-cli 2.59.0 *
core 2.59.0 *
telemetry 1.1.0
Extensions:
acrcssc 0.1.0 (dev) C:\git\azure-cli-extensions\src\acrcssc
Dependencies:
msal 1.27.0
azure-mgmt-resource 23.1.0b2
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\cegraybl.azure\cliextensions'
Development extension sources:
C:\git\azure-cli-extensions
Python (Windows) 3.11.8 (tags/v3.11.8:db85d51, Feb 6 2024, 21:52:07) [MSC v.1937 32 bit (Intel)
Additional context
For another sample, the example in the help for a file task is broken too
cat task.yaml | az acr task create -n hello-world -r myregistry -f - -c /dev/null
--schedule "0 */1 * * *"
az acr task create -n hello-world -r myregistry -f - -c /dev/null --schedule "0 */1 * * *"