Search code examples
powershellazurepowershell-cmdlet

What should I use in place of Select-AzureSubscription?


I am trying to remove deprecated cmdlets in a powershell script and one of the cmdlets is Select-AzureSubscription. I tried replacing it with Select-AzureRmSubscription but that requires user interaction to authenticate. Does anyone know what Azure-Rm cmdlet I should be using instead?


Solution

  • Select-AzureRmSubscription does change the approach that Azure uses for authentication. I had the same pain points when I converted my scripts.

    The official way of approaching this via scripting is as follows -

    $profile = Login-AzureRmAccount 
    
    Save-AzureRMProfile  -Profile $profile -path $path
    

    You can then use Select-AzureRmSubscription to none-interactively load those saved profiles.

    Although ultimately I didn't go this route, I decided to add another layer of security and use a machine based certificate to encrypt / decrypt credentials to pass to Login-AzureRmAccount This way I could manage multiple sets of accounts and never have to be concerned about those tokens being exposed on vulnerable machines.