I want to install the Az.ManagedServiceIdentity in Self-Hosted Agent Pool in ADO. Does it require access and Az.Connect and Az.Account commands. I want to create an user assigned identity using below command - New-AzUserAssignedIdentity -ResourceGroupName PSRG -Name ID1 [I'm referring this link - https://learn.microsoft.com/en-us/powershell/module/az.managedserviceidentity/new-azuserassignedidentity?view=azps-5.8.0#examples] But getting Error that command is not recognized. Also this command does not work on Azure Agent pool as well and I'm getting the same error. What are the dependencies for to install the Az.ManagedServiceIdentity module.
How to install module Az.ManagedServiceIdentity in Self-Hosted Agent Pool in ADO
811 Views Asked by Yogesh Kulkarni At
2
There are 2 best solutions below
0

Pls use Azure PowerShell task for this.
This task is used to run a PowerShell script within an Azure environment. The Azure context is authenticated with the provided Azure Resource Manager service connection.
YAML snippet:
# Azure PowerShell
# Run a PowerShell script within an Azure environment
- task: AzurePowerShell@5
inputs:
#azureSubscription: Required. Name of Azure Resource Manager service connection
#scriptType: 'FilePath' # Optional. Options: filePath, inlineScript
#scriptPath: # Optional
#inline: '# You can write your Azure PowerShell scripts inline here. # You can also pass predefined and custom variables to this script using arguments' # Optional
#scriptArguments: # Optional
#errorActionPreference: 'stop' # Optional. Options: stop, continue, silentlyContinue
#failOnStandardError: false # Optional
#azurePowerShellVersion: 'OtherVersion' # Required. Options: latestVersion, otherVersion
#preferredAzurePowerShellVersion: # Required when azurePowerShellVersion == OtherVersion
#pwsh: true # Optional. If true, then will use PowerShell Core pwsh.exe
Thanks for Yogesh Kulkarni's sharing that rebooting Agent Pool to make it find the new software. And it seems that rebooting is required to find new installed software and then register it to the service.
BTW, it is recommended to use Azure PowerShell task to run a PowerShell script within an Azure environment as singhh-msft replied.