Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.97k forks source link

Adding identity to group after creation #13354

Open Olli64 opened 4 years ago

Olli64 commented 4 years ago

Greetings!

I have a script that creates identities and assigns them to a AD Group that is also created in the same script.

If I create Identity and try to add it to the group with az ad group member add; it throws an error: Resource '<guidhere>' does not exist or one of its queried reference-property objects are not present.

I know that if I wait for atleast 30 seconds and add then, it succeeds.

How can I know when I am able to add the identity to the group?

I tried to make while loop to check that identity exists but it throws the same error because it exists as soon as it is created...

steps to reproduce (Powershell): az ad group create --display-name "testgroup" --mail-nickname "testgroup" $identity = az identity create -g "someresourcegroup" -n "testidentity" | ConvertFrom-JSON az ad group member add --group "testgroup" --member-id $identity.principalId

I've made an "hack" to sleep for 30 seconds after creating the identity and it works that way, but would be awesome to actually know when you can add it to the group.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

yonzhan commented 4 years ago

@arrownj please take a look

arrownj commented 4 years ago

Hi @vladimirjoanovic @rthorn17 , could you please also help check this problem? Is there any async tasks in the service side which leads this problem ? Thanks ahead.

rthorn17 commented 4 years ago

@arrownj Do we know what API's are being called by PowerShell? Are these ARM API's or AAD Graph API's?