-1

在使用 ARM 模板从 AZ 命令行成功部署 KafkaCluster 数周后,最近它不再工作,ARM template并且parameter. 运行后AZ deployment command它会抛出异常。

az deployment group create --resource-group XX --template-spec "/subscriptions/xxx/versions/1.0" --parameters ./environment/deploy/kafka/parameters.json --debug # to debug

运行命令后,Kafka 的模板正在打印正确的参数,在日志末尾有一些异常:

...
  "type": "Microsoft.Resources/templateSpecs/versions",
  "name": "1.0"
}
azure.cli.core.util.handle_exception is called with an exception:
Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 688, in _run_job
    result = cmd_copy(params)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 325, in __call__
    return self.handler(*args, **kwargs)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/__init__.py", line 784, in default_command_handler
    return op(**command_args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/resource/custom.py", line 511, in deploy_arm_template_at_resource_group
    no_prompt=no_prompt, template_spec=template_spec)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/resource/custom.py", line 538, in _deploy_arm_template_at_resource_group
    no_prompt=no_prompt, template_spec=template_spec)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/command_modules/resource/custom.py", line 830, in _prepare_deployment_properties_unmodified
    template_obj = show_resource(cmd=cmd, resource_ids=[template_spec]).properties['template']
KeyError: 'template'
During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/arm.py", line 103, in handle_template_based_exception
    raise CLIError(ex.inner_exception.error.message)
AttributeError: 'KeyError' object has no attribute 'inner_exception'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 215, in invoke
    cmd_result = self.invocation.execute(args)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 654, in execute
    raise ex
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 718, in _run_jobs_serially
    results.append(self._run_job(expanded_arg, cmd_copy))
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 709, in _run_job
    cmd_copy.exception_handler(ex)
  File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/arm.py", line 105, in handle_template_based_exception
    raise CLIError(ex)
knack.util.CLIError: 'template'

这里有什么问题?欢迎任何建议。

4

1 回答 1

0

问题出在 Jenkins 用于触发部署的参数文件中,这是修复从命令行传递 ARM 模板参数而不是从文件中读取它们的简单方法。

--parameters 'clusterName=XX' 'clusterLoginUserName=XX' 'clusterLoginPassword=XX' 'location=XX' 'clusterVersion=4.0' 'clusterKind=XX' 'sshUserName=XX' 'sshPassword=XX' 'minTlsVersionNumber=1.2'
于 2021-05-09T13:17:41.830 回答