K8s Extension failing due to AttributeError: 'DeploymentsOperations' object has no attribute 'begin_create_or_update'
In our project we use a Powershell script to construct an Azure environment, including an Azure Arc resource to deploy a kubernetes cluster. For the final step we set up azure monitor for containers using the the K8s Extension call. It's been working just fine for around 2-3 weeks, but recently we've been seeing failures in our script that are traced to this error:
File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/custom.py", line 134, in create_k8s_extension 2021-05-25 17:46:15.221704: config_protected_settings, configuration_settings_file, configuration_protected_settings_file) 2021-05-25 17:46:15.221715: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 60, in Create 2021-05-25 17:46:15.221745: configuration_protected_settings, is_ci_extension_type) 2021-05-25 17:46:15.221757: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 426, in _get_container_insights_settings 2021-05-25 17:46:15.221771: _ensure_container_insights_for_monitoring(cmd, workspace_resource_id).result() 2021-05-25 17:46:15.221784: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 385, in _ensure_container_insights_for_monitoring 2021-05-25 17:46:15.221804: validate=False, no_wait=False, subscription_id=subscription_id) 2021-05-25 17:46:15.221815: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 110, in _invoke_deployment 2021-05-25 17:46:15.221844: return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment) 2021-05-25 17:46:15.221860: AttributeError: 'DeploymentsOperations' object has no attribute 'begin_create_or_update'
The command we use to call the K8s extension is:
az k8s-extension create
--name "azuremonitor-containers"
--cluster-name "$CLUSTER_NAME"
--resource-group "$RESOURCE_GROUP"
--cluster-type "connectedClusters"
--extension-type "Microsoft.AzureMonitor.Containers" \
I know this call is in Preview and may have changed, but I haven't seen anything in the documentation reflecting this yet. Any help would be appreciated.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 3725c06d-f248-3b8b-5086-db601923786a
- Version Independent ID: 62142c2e-3bb6-c25c-01b9-12fc0eb8cb1d
- Content: az k8s-extension
- Content Source: latest/docs-ref-autogen/k8s-extension.yml
- GitHub Login: @rloutlaw
- Microsoft Alias: routlaw
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @Azure/aks-pm.
Issue Details
In our project we use a Powershell script to construct an Azure environment, including an Azure Arc resource to deploy a kubernetes cluster. For the final step we set up azure monitor for containers using the the K8s Extension call. It's been working just fine for around 2-3 weeks, but recently we've been seeing failures in our script that are traced to this error:
File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/custom.py", line 134, in create_k8s_extension 2021-05-25 17:46:15.221704: config_protected_settings, configuration_settings_file, configuration_protected_settings_file) 2021-05-25 17:46:15.221715: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 60, in Create 2021-05-25 17:46:15.221745: configuration_protected_settings, is_ci_extension_type) 2021-05-25 17:46:15.221757: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 426, in _get_container_insights_settings 2021-05-25 17:46:15.221771: _ensure_container_insights_for_monitoring(cmd, workspace_resource_id).result() 2021-05-25 17:46:15.221784: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 385, in _ensure_container_insights_for_monitoring 2021-05-25 17:46:15.221804: validate=False, no_wait=False, subscription_id=subscription_id) 2021-05-25 17:46:15.221815: File "/root/.azure/cliextensions/k8s-extension/azext_k8s_extension/partner_extensions/ContainerInsights.py", line 110, in _invoke_deployment 2021-05-25 17:46:15.221844: return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment) 2021-05-25 17:46:15.221860: AttributeError: 'DeploymentsOperations' object has no attribute 'begin_create_or_update'
The command we use to call the K8s extension is:
az k8s-extension create
--name "azuremonitor-containers"
--cluster-name "$CLUSTER_NAME"
--resource-group "$RESOURCE_GROUP"
--cluster-type "connectedClusters"
--extension-type "Microsoft.AzureMonitor.Containers" \
I know this call is in Preview and may have changed, but I haven't seen anything in the documentation reflecting this yet. Any help would be appreciated.
Document Details
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
- ID: 3725c06d-f248-3b8b-5086-db601923786a
- Version Independent ID: 62142c2e-3bb6-c25c-01b9-12fc0eb8cb1d
- Content: az k8s-extension
- Content Source: latest/docs-ref-autogen/k8s-extension.yml
- GitHub Login: @rloutlaw
- Microsoft Alias: routlaw
| Author: | dapt1989 |
|---|---|
| Assignees: | - |
| Labels: |
|
| Milestone: | - |
route to service team
Our project has also started seeing this error today. We're executing the following Azure CLI command using PowerShell from an azure-hosted agent:
az aks create `
--name $Name `
--resource-group $ResourceGroup `
--node-vm-size $NodeVMSize `
--node-count 1 `
--service-principal $ServiceConnectionId `
--client-secret $ServiceConnectionSecret `
--node-resource-group $AKSNodeResourceGroupName `
--kubernetes-version 1.20.5 `
--workspace-resource-id $WorkspaceResourceId `
--enable-addons "monitoring" `
--generate-ssh-keys `
--tags $Tags `
--debug
Error message:
2021-05-26T17:36:49.0199827Z ERROR: az_command_data_logger: 'DeploymentsOperations' object has no attribute 'begin_create_or_update'
2021-05-26T17:36:49.0200445Z Traceback (most recent call last):
2021-05-26T17:36:49.0201384Z File "/opt/az/lib/python3.6/site-packages/knack/cli.py", line 231, in invoke
2021-05-26T17:36:49.0202055Z cmd_result = self.invocation.execute(args)
2021-05-26T17:36:49.0202894Z File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 657, in execute
2021-05-26T17:36:49.0203540Z raise ex
2021-05-26T17:36:49.0204334Z File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 720, in _run_jobs_serially
2021-05-26T17:36:49.0205062Z results.append(self._run_job(expanded_arg, cmd_copy))
2021-05-26T17:36:49.0206008Z File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 691, in _run_job
2021-05-26T17:36:49.0206669Z result = cmd_copy(params)
2021-05-26T17:36:49.0207565Z File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/__init__.py", line 328, in __call__
2021-05-26T17:36:49.0208257Z return self.handler(*args, **kwargs)
2021-05-26T17:36:49.0209175Z File "/opt/az/lib/python3.6/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
2021-05-26T17:36:49.0210059Z return op(**command_args)
2021-05-26T17:36:49.0210992Z File "/opt/az/azcliextensions/aks-preview/azext_aks_preview/custom.py", line 1271, in aks_create
2021-05-26T17:36:49.0211737Z cmd, addon_profiles[CONST_MONITORING_ADDON_NAME])
2021-05-26T17:36:49.0212816Z File "/opt/az/azcliextensions/aks-preview/azext_aks_preview/custom.py", line 2759, in _ensure_container_insights_for_monitoring
2021-05-26T17:36:49.0213645Z validate=False, no_wait=False, subscription_id=subscription_id)
2021-05-26T17:36:49.0214672Z File "/opt/az/azcliextensions/aks-preview/azext_aks_preview/custom.py", line 329, in _invoke_deployment
2021-05-26T17:36:49.0215748Z return sdk_no_wait(no_wait, smc.begin_create_or_update, resource_group_name, deployment_name, deployment)
2021-05-26T17:36:49.0216824Z AttributeError: 'DeploymentsOperations' object has no attribute 'begin_create_or_update'
Any updates on this at all from the service team?
On my side of things, this seems to be unblocked. We are actively targeting version 0.3.0, is this the latest version and has there been any changes that would have caused this to be unblocked? If so I'd be happy to close this issue.
@dapt1989 @marlowp This issue should be due to the migration of Track 2 in CLI, and the compatibility code has been added in the latest version of extension. However, you haven't upgraded the CLI to the latest version. So please use az upgrade --yes to upgrade your CLI version.
@zhagao-ms this issue went away for us after a couple of days without any change on our side. The command was being run by a ubuntu-18.04 azure-hosted agent via a DevOps pipeline so perhaps the azure-hosted agent wasn't using the latest CLI version? Happy to close this issue as well.
@marlowp Yes, DevOps pipeline was not using the latest CLI version before, but it has been updated now. Therefore, I close this issue.