Using CLI 2.0 with the Azure German Cloud


I wrote these articles about the Azure CLI but that was at version 0.10.8 and things have progressed since then.  #Azure #AzureGermanCloud #GermanCloud #CLI

Here is some good CLI 2.0 information.

It is becoming very apparent, well, it has been this way for some time now that although I work at Microsoft I find myself using many, many open source technologies like never before.  This is one of those cases, here are a few others I have documented:

This article specifically explains how I installed Azure CLI 2.0 and then logged into my Azure subscriptions, both in the Azure public cloud and the Azure German Cloud.  Here is how I did it:

  1. Download and install Python
  2. Install Azure CLI 2.0 with bash
  3. Execute the ‘az’ commands set the environment and login

Download and install Python

I downloaded the 32bit version of Python from here, 3.6.1 was the most recent version at the time.  See Figure 1.

image

Figure 1, download python for Azure CLI 2.0 activity

I downloaded the EXE installation package and installed it as seen in Figure 2.

image

Figure 2, install python for Azure CLI 2.0 activity

Install Azure CLI 2.0 with bash

As per the instructions here, I executed the following python / pip commands:

python --version
pip install --user azure-cli

The output may be something similar as shown in Figure 3.

image

Figure 3, install Azure CLI 2.0 using python and pip

Execute the ‘az’ commands set the environment and login

You need to navigate to the location of the az.bat file or set that path in your environment settings.  Regardless the path is:

%USERPROFILE%\AppData\Roaming\Python\PythonXY\Scripts where XY is your Python version

Once you have done either of the above, execute the az. bat and you may see something similar to that shown in Figure 4.

image

Figure 4, execute Azure CLI 2.0 using az.bat or simply az

If this is the first time you are running this or perhaps at some time in the future, you want to most often be on the most current version of the toolset.  Execute the following command as shown also in Figure 5.

az component update

image

Figure 5, how to update Azure CLI to the most current version

By default, the Azure Environment you would attempt to access is AzureCloud which is the public cloud.  If you need to access the Azure German Cloud then you need to set the environment name to AzureGermanCloud by using this command also shown in Figure 6.

az cloud set --name AzureGermanCloud

image

Figure 6, how to login to the Azure German Cloud using Azure CLI 2.0

Then execute the following command, also shown in Figure 6 to login.

az login

This will provide render a URL that you need to put into a browser and enter the associated code.  Once authenticated, you can execute other az commands.  Notice the small difference in the URL for the public cloud versus the German Cloud.

C:\Users\UID>az context list
[
  {
    "active": true,
    "cloud": "AzureCloud",
    "name": "default"
  }
]

C:\Users\UID>az context modify --cloud AzureGermanCloud

C:\Users\UID>az context list
[
  {
    "active": true,
    "cloud": "AzureGermanCloud",
    "name": "default"
  }
]

C:\Users\UID>az login -u <MyAccount> -p <MyPassword>
[
  {
    "cloudName": "AzureGermanCloud",
    "id": "xxx-xxx-xxx-xxx-xxx",
    "isDefault": true,
    "name": "Germany - Internal Consumption",
    "state": "Enabled",
    "tenantId": "xxx-xxx-xxx-xxx-xxx",
    "user": {
      "name": "???@***.onmicrosoft.de",
      "type": "user"
    }
  }
]

Comments (0)

Skip to main content