Powershell – Azure Powershell – Staying Logged in

azurepowershell

I need to be able to store many azure subscriptions and load them when needed.

I have saved the profile with…

Save-AzureRmProfile -Path 'C:\Temp\profile.json'

Then i can load it with

Select-AzureRmProfile -Path 'C:\Temp\profile.json'

The after a few days the token expires and i can no longer load the subscription

Your Azure credentials have not been set up or have expired

Whats the best way to store subscriptions for Resource Manager?

Best Answer

Please use certificate method:- This method requires you create a “publishSettingFile” from the Azure management portal (using PowerShell) then import that file into PowerShell.

Sign in to account on the Azure Management Portal. Open the Azure PowerShell console in an elevated state. Type the following command:Get-AzurePublishSettingsFile If you are logged into you azure account a download will launch in your web browser.[note] To avoid issues when multiple browsers are installed. make sure you log into Azure portal using your “Default” web browser [/note] Save the publishing profile file. Type the following command substituting the path for the location of where you saved the publishing profile file:Import-AzurePublishSettingsFile C:\Users\\Downloads\-credentials.publishsettings

Related Topic