Skip to content

Caching credentials with Azure CLI

Ian Hellen edited this page Sep 13, 2021 · 4 revisions

My user account/credentials do not get cached between notebook runs You can force caching of credentials for a session by authenticating using Azure CLI.

You must have Azure CLI installed on the Jupyter server you are using (e.g. Azure ML Compute). Azure ML Compute instances have Azure CLI installed by default. Use this URL to obtain the latest Azure CLI, if you need to install it.

In an empty cell, type and execute the following:

!az login

You can also do this by opening a terminal on the Jupyter server/AML compute and executing the following from the shell prompt

az login

You should see the following prompt (in barely readable text if you are using the default light theme):

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code AMEE5STGD to authenticate. Select and copy the 9 character token and click on the devicelogin URL. Paste the token into the dialog at that page and proceed with the login as prompted.

When login has successfully completed you should see the following output, which is a list of subscriptions that your account has access to:

Subscription 74bd0f79-3e18-4be4-90c5-0c46007ab514 'Sample subscription' can be accessed from tenants 2a0b016c-36fa-4569-974e-37b05956597c(default) and 45775191-e432-4364-a1cd-b97da6816cb4. To select a specific tenant when accessing this subscription, use 'az login --tenant TENANT_ID'.
The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access.
e8f78f0f-3f2b-4342-a36c-7e91db929057 'foo'
0aa0847b-6374-4acc-a76c-a09e92a84c56 'bar'
[
  {
    "cloudName": "AzureApp",
    "homeTenantId": "2a0b016c-36fa-4569-974e-37b05956597c",
    "id": "53b762ad-56f2-4c8f-b7e9-5eab95793ba5",
    "isDefault": true,
    "managedByTenants": [

You can ignore this output.