az ad group member add is not idempotent
az feedbackauto-generates most of the information requested below, as of CLI version 2.0.62
Describe the bug I'm running this command from an Azure DevOps pipeline as part of our infrastructure deployment and without additional care these commands fail for subsequent runs.
To Reproduce az ad group member add -g $rg --member-identity $id az ad group member add -g $rg --member-identity $id
One or more added object references already exist for the following modified properties: 'members'.
Expected behavior No error.
Environment summary
azure-cli 2.19.1
core 2.19.1
telemetry 1.0.6
Extensions:
datafactory 0.2.0
azure-devops 0.18.0
resource-graph 1.1.0
application-insights 0.1.5
image-copy-extension 0.0.7
Additional context I've run the same command on ubuntu, macOs and Windows. Here's my workaround: https://twitter.com/MRiezebosch/status/1359533376777179137
Graph
Also encountering this problem. This is at odds with how almost everything else in Azure works; commands should be idempotent.
No fix for this since 2021..?!?
Thanks for the reports, and sorry this sat so long.
This is still a valid idempotency gap for automation. Microsoft Graph returns an error when the object is already a group member, and az ad group member add currently surfaces that error rather than treating the existing membership as success.
For now, the workaround is to check membership first with az ad group member check, then add only when needed.
Keeping this open as P2 to track making az ad group member add safer for repeat pipeline runs.