Azure / template-specs

MIT License
31 stars 4 forks source link

Unable to deploy template spec via Az cli. Throw error 'Template' #54

Closed warren-li closed 2 years ago

warren-li commented 3 years ago

Running

az deployment group create from az cli with --template-spec $id

would throw Error 'template'

Deploy using portal on template spec is fine.

detienne20 commented 3 years ago

@warren-li are you using the latest version of az cli that was released 05/06?

Version should be 2.23.0 when running az --version

warren-li commented 3 years ago

@detienne20 yeah tried that same issues, and all is working on 23 April 2021, it only throw this error when we try deploy on 10/05/2021 with the same code base.

Manage to go around the issues, by port all the deployment group create to use arm template to do the template spec deployment.

it work and deploy, and only have minor issues on validation arm bug where there is another open issues from someone on azure devop post using the AzureResourceManagerTemplateDeployment@3 task.

detienne20 commented 3 years ago

@warren-li can you please run the command using --debug and share the full output here? Was the template spec created with az cli?

warren-li commented 3 years ago

`cli.knack.cli: Command arguments: ['deployment', 'group', 'create', '--name', 'test', '--resource-group', 'rg-customer', '--template-spec', '/subscriptions/6cbe45a0-6565-4c4a-b1a9-0929f276bbcd/resourceGroups/rg-customer/providers/Microsoft.Resources/templateSpecs/ts-dev-st_customer_documents', '--debug'] cli.knack.cli: init debug log: Enable color in terminal. Init colorama. cli.knack.cli: Event: Cli.PreExecute [] cli.knack.cli: Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x03524190>, <function OutputProducer.on_global_arguments at 0x036A0028>, <function CLIQuery.on_global_arguments at 0x036B7BF8>] cli.knack.cli: Event: CommandInvoker.OnPreCommandTableCreate [] cli.azure.cli.core: Modules found from index for 'deployment': ['azure.cli.command_modules.resource'] cli.azure.cli.core: Loading command modules: cli.azure.cli.core: Name Load Time Groups Commands cli.azure.cli.core: resource 0.022 37 176 cli.azure.cli.core: Total (1) 0.022 37 176 cli.azure.cli.core: Loaded 37 groups, 176 commands. cli.azure.cli.core: Found a match in the command table. cli.azure.cli.core: Raw command : deployment group create cli.azure.cli.core: Command table: deployment group create cli.knack.cli: Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x03AC0100>] cli.azure.cli.core.azlogging: metadata file logging enabled - writing logs to 'C:\Users\Warren.Li.azure\commands\2021-05-13.13-57-16.deployment_group_create.18168.log'. az_command_data_logger: command args: deployment group create --name {} --resource-group {} --template-spec {} --debug cli.knack.cli: Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument..add_subscription_parameter at 0x03B062B0>, <function register_global_query_examples_argument..register_query_examples at 0x03B14970>] cli.knack.cli: Event: CommandInvoker.OnPostArgumentLoad [] cli.knack.cli: Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument..add_ids_arguments at 0x03B149B8>, <function register_cache_arguments..add_cache_arguments at 0x03B14A48>] cli.knack.cli: Event: CommandInvoker.OnCommandTableLoaded [] cli.knack.cli: Event: CommandInvoker.OnPreParseArgs [] cli.knack.cli: Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x036A0070>, <function CLIQuery.handle_query_parameter at 0x036B7C40>, <function register_global_query_examples_argument..handle_example_parameter at 0x03B06388>, <function register_ids_argument..parse_ids_arguments at 0x03B14A00>] Argument '--template-spec' is in preview and under development. Reference and support levels: https://aka.ms/CLI_refstatus msrest.serialization: mode is not a known attribute of class <class 'azure.mgmt.resource.resources.v2020_10_01.models._models.TemplateLink'> and will be ignored cli.azure.cli.core.commands.client_factory: Getting management service client client_type=ResourceManagementClient msrest.universal_http.requests: Configuring retry: max_retries=4, backoff_factor=0.8, max_backoff=90 cli.azure.cli.core.commands.client_factory: Adding custom headers to the client: cli.azure.cli.core.commands.client_factory: 'x-ms-client-request-id': 'be996acf-b3ea-11eb-a977-c0b8833852d8' cli.azure.cli.core.commands.client_factory: 'CommandName': 'deployment group create' cli.azure.cli.core.commands.client_factory: 'ParameterSetName': '--name --resource-group --template-spec --debug' cli.azure.cli.core.adal_authentication: AdalAuthentication.signed_session invoked by Track 1 SDK cli.azure.cli.core._profile: Retrieving token from ADAL for resource 'https://management.core.windows.net/' cli.azure.cli.core.util: attempting to read file C:\Users\Warren.Li.azure\accessTokens.json as utf-8-sig adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - Authority:Performing instance discovery: ... adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - Authority:Performing static instance discovery adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - Authority:Authority validated via static instance discovery adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - TokenRequest:Getting token from cache with refresh if necessary. adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - CacheDriver:finding with query keys: {'_clientId': '...', 'userId': '...'} adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - CacheDriver:Looking for potential cache entries: {'_clientId': '...', 'userId': '...'} adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - CacheDriver:Found 5 potential entries. adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - CacheDriver:Resource specific token found. adal-python: c47c4e62-40ea-4cc4-8b54-95b5da539f1f - CacheDriver:Returning token from cache lookup, AccessTokenId: b'FFaRDM6DS+3owONjaNKoVmtWTI97jVaogRMBl4wKQIs=', RefreshTokenId: b'PxYHNbY6DlX8dq7c7T4+KuO3DGqrHI/Zlw05i+eQf+g=' msrest.http_logger: Request URL: 'https://management.azure.com/subscriptions/6cbe45a0-6565-4c4a-b1a9-0929f276bbcd/resourceGroups/rg-customer/providers/Microsoft.Resources/templateSpecs/ts-dev-st_customer_documents?api-version=2019-06-01-preview' msrest.http_logger: Request method: 'GET' msrest.http_logger: Request headers: msrest.http_logger: 'Accept': 'application/json' msrest.http_logger: 'accept-language': 'en-US' msrest.http_logger: 'User-Agent': 'python/3.8.9 (Windows-10-10.0.18362-SP0) msrest/0.6.21 msrest_azure/0.6.3 azure-mgmt-resource/12.1.0 Azure-SDK-For-Python AZURECLI/2.23.0 (MSI)' msrest.http_logger: Request body: msrest.http_logger: None msrest.universal_http: Configuring redirects: allow=True, max=30 msrest.universal_http: Configuring request: timeout=100, verify=True, cert=None msrest.universal_http: Configuring proxies: '' msrest.universal_http: Evaluate proxies against ENV settings: True urllib3.connectionpool: Starting new HTTPS connection (1): management.azure.com:443 urllib3.connectionpool: https://management.azure.com:443 "GET /subscriptions/6cbe45a0-6565-4c4a-b1a9-0929f276bbcd/resourceGroups/rg-customer/providers/Microsoft.Resources/templateSpecs/ts-dev-st_customer_documents?api-version=2019-06-01-preview HTTP/1.1" 200 None msrest.http_logger: Response status: 200 msrest.http_logger: Response headers: msrest.http_logger: 'Cache-Control': 'no-cache' msrest.http_logger: 'Pragma': 'no-cache' msrest.http_logger: 'Transfer-Encoding': 'chunked' msrest.http_logger: 'Content-Type': 'application/json; charset=utf-8' msrest.http_logger: 'Content-Encoding': 'gzip' msrest.http_logger: 'Expires': '-1' msrest.http_logger: 'Vary': 'Accept-Encoding' msrest.http_logger: 'x-ms-request-id': '74b14702-6e0b-459c-ac47-43efa96103ea' msrest.http_logger: 'Server': 'Microsoft-HTTPAPI/2.0' msrest.http_logger: 'x-ms-ratelimit-remaining-subscription-reads': '11999' msrest.http_logger: 'x-ms-correlation-request-id': '1b447a5a-e5e4-4436-9af7-74b7c2f66089' msrest.http_logger: 'x-ms-routing-request-id': 'UKSOUTH:20210513T125717Z:1b447a5a-e5e4-4436-9af7-74b7c2f66089' msrest.http_logger: 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' msrest.http_logger: 'X-Content-Type-Options': 'nosniff' msrest.http_logger: 'Date': 'Thu, 13 May 2021 12:57:16 GMT' msrest.http_logger: Response content: msrest.http_logger: { "location": "uksouth", "tags": {}, "systemData": { "createdBy": "1d3621de-0e64-4199-b0be-b1473cd4bedf", "createdByType": "Application", "createdAt": "2021-02-17T12:21:09.851361Z", "lastModifiedBy": "1d3621de-0e64-4199-b0be-b1473cd4bedf", "lastModifiedByType": "Application", "lastModifiedAt": "2021-05-11T10:08:31.9043095Z" }, "properties": {}, "id": "/subscriptions/6cbe45a0-6565-4c4a-b1a9-0929f276bbcd/resourceGroups/rg-customer/providers/Microsoft.Resources/templateSpecs/ts-dev-st_customer_documents", "type": "Microsoft.Resources/templateSpecs", "name": "ts-dev-st_customer_documents" } cli.azure.cli.core.util: azure.cli.core.util.handle_exception is called with an exception: cli.azure.cli.core.util: Traceback (most recent call last): File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 691, in _run_job File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 328, in call File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/command_operation.py", line 121, in handler File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 538, in deploy_arm_template_at_resource_group File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 567, in _deploy_arm_template_at_resource_group File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/command_modules/resource/custom.py", line 900, in _prepare_deployment_properties_unmodified KeyError: 'template'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 100, in handle_template_based_exception AttributeError: 'KeyError' object has no attribute 'inner_exception'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\knack/cli.py", line 231, in invoke File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 657, in execute File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 720, in _run_jobs_serially File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/init.py", line 712, in _run_job File "D:\a\1\s\build_scripts\windows\artifacts\cli\Lib\site-packages\azure/cli/core/commands/arm.py", line 102, in handle_template_based_exception knack.util.CLIError: 'template'

cli.azure.cli.core.azclierror: 'template' az_command_data_logger: 'template' cli.knack.cli: Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x03AC0220>] az_command_data_logger: exit code: 1 cli.main: Command ran in 1.128 seconds (init: 0.208, invoke: 0.919) telemetry.save: Save telemetry record of length 3047 in cache telemetry.check: Negative: The C:\Users\Warren.Li.azure\telemetry.txt was modified at 2021-05-13 13:54:40.309220, which in less than 600.000000 s`

warren-li commented 3 years ago

`azure-cli 2.23.0

core 2.23.0 telemetry 1.0.6

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe' Extensions directory 'C:\Users\Warren.Li.azure\cliextensions'

Python (Windows) 3.8.9 (tags/v3.8.9:a743f81, Apr 6 2021, 13:22:56) [MSC v.1928 32 bit (Intel)]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Please let us know how we are doing: https://aka.ms/azureclihats and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy`

warren-li commented 3 years ago

@detienne20 sorry for the late reply, the above is my az --version and the output of the --debug.

detienne20 commented 3 years ago

@warren-li Thank you for your patience. The latest version of CLI will be released on 5/25. If you are still seeing this issue then, this might an issue with your installation, please reinstall and let us know if the issue persists then.

stuartko commented 2 years ago

Closing this issue given we haven't received further follow-ups regarding this still being an issue after the June release.