Skip to content
adatum
  •  Learn Azure Bicep
  •  SCOM Web API
  •  About adatum
Azure

Multiple Azure credentials in PowerShell

  • 06/05/202002/09/2020
  • by Martin Ehrnst

Environments in Azure are often separated into multiple subscriptions, in some cases multiple tenants. This sectioning can also result in multiple user accounts, and managing multiple Azure credentials can be challenging. Luckily, Azure PowerShell has this capability called context.

Although the documentation is solid on the topic. It doesn’t necessarily provide the backdrop for when you will need to use this feature.

A few weeks ago I had to move a set of APIs from one instance of Azure API management to another. With PowerShell contexts, I could download the API from the origin and import it to the new instance.

Connecting to multiple Azure environments using context

To hold credential information, like user and subscription. PowerShell uses context objects. By using AzContext comandlets You can have multiple Powershell Azure contexts available in the same PowerShell session. This allows for easy switching between multiple environments and profiles. Including different tenants.

Below is an example of how you can connect to multiple tenants and switch between the credentials and contexts. I recommend using friendly names which will make them easier to identify.

Azure PowerShell context

Share this:

  • LinkedIn
  • Twitter
  • Reddit

Related

Jumpstart your Azure Monitor journey
IT Pro announcements from Microsoft Build
Azure Powershell

Related articles

Track changes to Azure resources
How to move Azure blobs…
microsoft social sign-in
Azure Application registrations, Enterprise Apps,…
gray laptop computer showing html codes in shallow focus photography
Azure Infrastructure As Code video…
flight sky earth space
Recording available: ARM template deployment…
3 COMMENTS
  • To Azure Powershell Logga In - SwedenSpace
    12/03/2022 at 03:21
    Reply

    […] Multiple Azure credentials in PowerShell – adatum […]

  • PowerShell SnippetRace 19-2020 | | PowerShell Usergroup Austria
    10/05/2020 at 18:55
    Reply

    […] If you have to deal with multiple Azure credentials, its sometimes time-consuming to switch between those. Martin Ehrnst wrote some code to explain Azure context. Link […]

  • ICYMI: PowerShell Week of 08-May-2020 – 247 TECH
    09/05/2020 at 00:36
    Reply

    […] Multiple Azure credentials in PowerShell […]

Engage by commenting Cancel reply

Top Posts & Pages

  • Azure Application registrations, Enterprise Apps, and managed identities
  • Automate Azure DevOps like a boss
  • Multi subscription deployment with DevOps and Azure Lighthouse
  • Creating Azure AD Application using Powershell
  • Azure token from a custom app registration
  • Azure AD authentication in Azure Functions
  • How to move Azure blobs up the path
  • Script to add SCOM agent management group
  • Track changes to Azure resources
  • Azure Bicep modules, variables, and T-shirt sizing

Tags

agent announcements api ARM authoring Automation azcopy Azure AzureAD Azure Bicep AzureDevOps AzureFunctions AzureLighthouse AzureManagement AzureMonitor AzureSpringClean Bicep Community CSP database EventGrid healthservicestore IaC Infrastructure as code Integrations logs management pack Microsoft Build Microsoft Partner monitoring MSIgnite MSOMS MSP nicconf Nordic Virtual Summit OperationsManager OpsMgr Powershell QUickPublish rest SCOM Serverless SquaredUP SysCtr system center

Follow Martin Ehrnst

  • Twitter
  • LinkedIn

RSS feed RSS - Posts

RSS feed RSS - Comments

Microsoft Azure MVP

Martin Ehrnst Microsoft Azure MVP
Adatum.no use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. Cookie Policy
Theme by Colorlib Powered by WordPress