Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Select-AzureRMSubscription not recognized

Trying to set up my VSTS windows build agent to accommodate for powershell steps within VSTS but having some problems. Initially it reported that the AzurePS system capability was not present, so I made sure to install the latest Azure modules via the powershell gallery. Now, the AzurePS capability is present but certain powershell commands do not seem to work.

This may not be related to VSTS at all but rather just a configuration issue with my specific powershell installation / configuration. The full error is as follows:

The term 'Select-AzureRMSubscription' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

This error can be seen both in the VSTS release logs of the particular definition I am trying to execute, as well as when attempting to run the Select-AzureRMSubscription command directly on the box itself.

like image 591
kellerto Avatar asked Oct 18 '25 14:10

kellerto


2 Answers

According to This MS Docs for Get-AzSubscription it's located in the module Az.Accounts.

So I had to run:

Install-module Az -AllowClobber -Force
Import-module Az

to make the command avaliable to me.

like image 141
Andreas Avatar answered Oct 20 '25 08:10

Andreas


For me, updating the AzureRM module did the trick:

Update-Module -Name AzureRM

Depending on your system, you may get some messages while installing

Powershell requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or 'C:\Users\<...>\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running Install-PackagePovider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?

[Yes] {No] [Suspend]

Choose "Yes"

You are installling the modules form an untrusted repository. If you trust this repository, change its installationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?

[Yes] [Yes to All] [No] [No to All] [Suspend]

Choose "Yes to all" Up to three modules will be installed/updated and directly after that, the Select-AzureRmSubscription should work immediately.

Select-AzureRmSubscription b0cabaca-1234-1337-abcd-bebedada1337

# note: this subscription GUID is completely fictional.
# To get the correct one, query your subscriptions with
# Get-AzureRmSubscription
like image 35
realbart Avatar answered Oct 20 '25 07:10

realbart