Azure / Azure/azure-powershell
Unable to login to User Assigned Identities in the Az Powershell in the local system/ powersh runbook
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description
Hello Team ,
I tried the following code and getting the error.
Connect-AzAccount -Identity -AccountId $identity.ClientId
WARNING: Unable to acquire token for tenant 'organizations' with error 'ManagedIdentityCredential authentication unavailable. Multiple attempts failed to obtain a token from the managed identity endpoint.'
I tried from the Ref #: https://learn.microsoft.com/en-us/azure/automation/migrate-run-as-accounts-managed-identity?tabs=ua-managed-identity
I want to login to the Automation account and access the system's and resources. I gave the access in the IAM role in the Automation. Despite doing so, it desperately fails.
request you to help me find a way to work on both localsystem and the runbook as should be.
additionally, let me know if you get me a way to get the list systems ( VMs) available / linked to the automation account.
Humble Thanks.
Thank you.
Reagrds ,
Libin
### Script or Debug output
```PowerShell
try
{
"Logging in to Azure..."
$identity = Get-AzUserAssignedIdentity -ResourceGroupName -Name
Connect-AzAccount -Identity -AccountId $identity.ClientId
}
catch {
Write-Error -Message $_.Exception
throw $_.Exception
}
#Get all Resource Manager resources from all resource groups
$ResourceGroups = Get-AzResourceGroup
foreach ($ResourceGroup in $ResourceGroups)
{
Write-Output ("Showing resources in resource group " + $ResourceGroup.ResourceGroupName)
$Resources = Get-AzResource -ResourceGroupName $ResourceGroup.ResourceGroupName
foreach ($Resource in $Resources)
{
Write-Output ($Resource.Name + " of type " + $Resource.ResourceType)
}
Write-Output ("")
}
Ref#: https://learn.microsoft.com/en-us/azure/automation/migrate-run-as-accounts-managed-identity?tabs=ua-managed-identity
Under the section : User Assigned Identity.
```
### Environment data
```PowerShell
PS> $PSVersionTable
Name Value
---- -----
PSVersion 7.3.1
PSEdition Core
GitCommitId 7.3.1
OS Microsoft Windows 10.0.25246
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```
### Module versions
```PowerShell
PS> Get-Module Az*
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.10.4 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 1.8.0 Az.Automation {Export-AzAutomationDscConfiguration, Export-AzAutomationDscNodeReportContent, Export-AzAutomationRun…
Script 5.2.0 Az.Compute {Add-AzImageDataDisk, Add-AzVhd, Add-AzVMAdditionalUnattendContent, Add-AzVMDataDisk…}
Script 1.1.0 Az.ManagedServiceIdentity {Get-AzFederatedIdentityCredentials, Get-AzSystemAssignedIdentity, Get-AzUserAssignedIdentity, Get-Az…
```
### Error output
_No response_
Contributor guide
Research direction
Start by reviewing the User Assigned Identity section of the linked migration guide and the Connect-AzAccount -Identity entry point. Compare the command's behavior in the local PowerShell session and the Automation runbook, using the reported Az.Accounts 2.10.4 environment. Done means the supported authentication path and the method for listing linked VMs are clearly established.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure, powershell
- Domain
- authentication, cloud
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100