Hi,
I suspect Get-AzUserAssignedIdentity
is expecting a subscription ID as there is no Azure context set in the script at the time of running the cmdlet.
I suggest using the Connect-AzAccount
cmdlet as follows for connecting:
Connect-AzAccount -Identity -AccountId <user-assigned-identity-ClientId>
For the -AccountId
parameter you can find the identifier on the overview plane for the managed identity, under Client ID.
A relevant documentation can be found here.
Edit:
Afterwards the Set-AzContext
cmdlet can be used to set the subscription explicitly, however if the identity has access to only one subscription, it should default to that one.
If you don't want to "hard code" the client ID into the script itself, it can be moved to an automation variable and the Get-AutomationVariable -Name <variable-name>
internal cmdlet can be used without authentication towards Azure.
BR,
Peter