Skip to content

[amg] az grafana update --smtp fails with AttributeError when grafanaConfigurations is null #34480

Open

Description

Describe the bug

az grafana update with SMTP options crashes with an unhandled AttributeError when the Azure Managed Grafana
instance has never had any grafanaConfigurations set (properties.grafanaConfigurations is null).
update_grafana dereferences instance.properties.grafana_configurations.smtp without a None check,
so SMTP can't be configured on a freshly created instance (e.g. one deployed by Bicep/ARM without that property).

Related command

az grafana update

Errors

ERROR: The command failed with an unexpected error. Here is the traceback:
ERROR: 'NoneType' object has no attribute 'smtp'
Traceback (most recent call last):
File "/opt/az/lib/python3.10/site-packages/knack/cli.py", line 233, in invoke
cmd_result = self.invocation.execute(args)
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 663, in execute
raise ex
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 726, in _run_jobs_serially
results.append(self._run_job(expanded_arg, cmd_copy))
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 697, in _run_job
result = cmd_copy(params)
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/init.py", line 333, in call
return self.handler(*args, **kwargs)
File "/opt/az/lib/python3.10/site-packages/azure/cli/core/commands/command_operation.py", line 121, in handler
return op(**command_args)
File "/opt/az/azcliextensions/amg/azext_amg/custom.py", line 208, in update_grafana
if not instance.properties.grafana_configurations.smtp:
AttributeError: 'NoneType' object has no attribute 'smtp'

Issue script & Debug output

Grafana instance (Standard SKU) created via Bicep with no grafanaConfigurations

az extension add --name amg --upgrade --yes

az grafana update -g -n
--smtp enabled
--host smtp.azurecomm.net:587
--user
--password @
--from-address
--from-name ""
--start-tls-policy OpportunisticStartTLS
--skip-verify false
--debug

<to fill in: debug output with tokens, subscription IDs and the SMTP password removed>

Expected behavior

SMTP settings are applied to the instance, creating grafanaConfigurations if it doesn't already exist,
the same as when the instance already has SMTP configured.

Environment Summary

<to fill in: output of az --version>

Observed on: azure-cli 2.51.0, amg extension installed via az extension add --name amg --upgrade
(exact version not captured), Ubuntu 22.04, Azure DevOps self-hosted agent (AzureCLI@2 task, PowerShell Core).

Additional context

  • Grafana API version used by the extension: 2023-09-01.
  • Workaround: PATCH the resource directly, which works when grafanaConfigurations is null:
    az rest --method patch --url "https://management.azure.com?api-version=2023-09-01" --body @body.json
    with body {"properties":{"grafanaConfigurations":{"smtp":{"enabled":true,"host":"...","user":"...","password":"...","fromAddress":"...","fromName":"...","startTLSPolicy":"OpportunisticStartTLS","skipVerify":false}}}}
  • In amg 3.1.1 the update command appears to be generated (aaz) code and may no longer contain this path;
    please confirm whether this is fixed in current versions.

Activity

  1. added
    bug
    on Nov 23, 2026
  2. added
    customer-reported
    Auto-Assign
    Service Attention
    on Nov 23, 2026
  3. added
    amg
    on Nov 23, 2026
  4. yonzhan commented on Nov 23, 2026

    @yonzhan
    Collaborator

    route to service team

  5. microsoft-github-policy-service commented on Nov 23, 2026

    @microsoft-github-policy-service
    Contributor

    Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @ABZhang0.

  6. Aadithya2222 commented on Nov 24, 2026

    @Aadithya2222

    Hi maintainers,

    I'd like to work on this issue and investigate the AttributeError occurring when grafanaConfigurations is null during the az grafana update --smtp operation.

    I can reproduce and investigate the issue, identify the appropriate fix, and add regression tests.

    Is this issue currently available for external contributions? If so, could you please assign it to me?

    Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Auto-AssignService Attentionamgbugcustomer-reported

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions