Azure Cloud Shell keeps resulting in "Key not found" error #9823

Closed
opened 2026-01-31 02:04:46 +00:00 by claunia · 24 comments
Owner

Originally created by @ghost on GitHub (Jul 24, 2020).

Originally assigned to: @DHowett on GitHub.

I keep seeing the following behavior:

Tenant 0: Default Directory (brillfoxyahoo.onmicrosoft.com)
Tenant 1: Microsoft (microsoft.onmicrosoft.com)
Please enter the desired tenant number.
Enter n to login with a new account
Enter r to remove the above saved connection settings.
> 1
Requesting a cloud shell instance...
Succeeded.
Key not found
[process exited with code 1]

This issue seems persistent.

Originally created by @ghost on GitHub (Jul 24, 2020). Originally assigned to: @DHowett on GitHub. I keep seeing the following behavior: ``` Tenant 0: Default Directory (brillfoxyahoo.onmicrosoft.com) Tenant 1: Microsoft (microsoft.onmicrosoft.com) Please enter the desired tenant number. Enter n to login with a new account Enter r to remove the above saved connection settings. > 1 Requesting a cloud shell instance... Succeeded. Key not found [process exited with code 1] ``` This issue seems persistent.
claunia added the Issue-BugNeeds-Tag-FixProduct-TerminalArea-AzureShell labels 2026-01-31 02:04:46 +00:00
Author
Owner

@Javanite commented on GitHub (Jul 27, 2020):

I have the same issue.

To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXX to authenticate.
This code will expire in 15 minutes.
Authenticated.
Tenant 0: xxx (xxx.onmicrosoft.com)
Tenant 1: xxx (xxx.onmicrosoft.com)
Tenant 2: xxx (xxx.onmicrosoft.com)
Tenant 3: xxx (xxx.onmicrosoft.com)
Please enter the desired tenant number.
> 0
Do you want to save these connection settings for future logins? [y/n]
> n
Requesting a cloud shell instance...
Succeeded.
Key not found
[process exited with code 1]

@Javanite commented on GitHub (Jul 27, 2020): I have the same issue. ``` To sign in, use a web browser to open the page https://microsoft.com/devicelogin and enter the code XXXXXXXX to authenticate. This code will expire in 15 minutes. Authenticated. Tenant 0: xxx (xxx.onmicrosoft.com) Tenant 1: xxx (xxx.onmicrosoft.com) Tenant 2: xxx (xxx.onmicrosoft.com) Tenant 3: xxx (xxx.onmicrosoft.com) Please enter the desired tenant number. > 0 Do you want to save these connection settings for future logins? [y/n] > n Requesting a cloud shell instance... Succeeded. Key not found [process exited with code 1] ```
Author
Owner

@DHowett commented on GitHub (Jul 27, 2020):

@Javanite I'm going to follow up with you offline, as I can furnish a debug build of the AzCS bridge 😄

@DHowett commented on GitHub (Jul 27, 2020): @Javanite I'm going to follow up with you offline, as I can furnish a debug build of the AzCS bridge :smile:
Author
Owner

@iAmSaugata commented on GitHub (Jul 30, 2020):

I am also having same issue.

Tenant 0: name
Please enter the desired tenant number.
Enter n to login with a new account
Enter r to remove the above saved connection settings.

help
Please enter a valid number to access the stored connection settings, n to log in with a new account, or r to remove the saved connection settings.
0
Requesting a cloud shell instance...
Succeeded.
Key not found
[process exited with code 1]

@iAmSaugata commented on GitHub (Jul 30, 2020): I am also having same issue. Tenant 0: name Please enter the desired tenant number. Enter n to login with a new account Enter r to remove the above saved connection settings. > help Please enter a valid number to access the stored connection settings, n to log in with a new account, or r to remove the saved connection settings. > 0 Requesting a cloud shell instance... Succeeded. Key not found [process exited with code 1]
Author
Owner

@Javanite commented on GitHub (Jul 30, 2020):

Hey @DHowett ,

Just a heads up I will be out the whole month of August, so I might be hard to reach. You can try pinging me on teams and I will respond if I can.

@Javanite commented on GitHub (Jul 30, 2020): Hey @DHowett , Just a heads up I will be out the whole month of August, so I might be hard to reach. You can try pinging me on teams and I will respond if I can.
Author
Owner

@yiigy commented on GitHub (Jul 30, 2020):

Likely due to the shell storage hasn't been setup yet. Login to your Azure Portal, select the Azure Shell on top to first initialize and setup the shell. Once the storage is completed, you should be able connect via Azure Cloud Shell.

@yiigy commented on GitHub (Jul 30, 2020): Likely due to the shell storage hasn't been setup yet. Login to your Azure Portal, select the Azure Shell on top to first initialize and setup the shell. Once the storage is completed, you should be able connect via Azure Cloud Shell.
Author
Owner

@Javanite commented on GitHub (Jul 31, 2020):

@yiigy thanks for the suggestion, unfortunately doesn't appear to work. I started up the cloud shell in the portal, even ran it in interactive mode, but I still get the same result as before when using the Windows Terminal.

Here's a screencap of me running a random command in the az portal cloud shell.

image

Attempting to connect afterwards:
image

@Javanite commented on GitHub (Jul 31, 2020): @yiigy thanks for the suggestion, unfortunately doesn't appear to work. I started up the cloud shell in the portal, even ran it in interactive mode, but I still get the same result as before when using the Windows Terminal. Here's a screencap of me running a random command in the az portal cloud shell. ![image](https://user-images.githubusercontent.com/19479604/88984737-434eae00-d283-11ea-8d21-ff25dad23d9f.png) Attempting to connect afterwards: ![image](https://user-images.githubusercontent.com/19479604/88984786-6d07d500-d283-11ea-82fb-6b5a98fe5230.png)
Author
Owner

@csijake commented on GitHub (Sep 23, 2020):

Having the same issue. Terminal Version: 1.2.2381.0

image

If these values matter:

pwsh --version: PowerShell 7.0.2
$PSVersionTable:

Key Value
PSEdition Core
PSCompatibleVersions System.Version[]
Platform Win32NT
GitCommitId 7.0.2
OS Microsoft Windows 10.0.18363
PSVersion 7.0.2
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
@csijake commented on GitHub (Sep 23, 2020): Having the same issue. Terminal Version: 1.2.2381.0 ![image](https://user-images.githubusercontent.com/65626696/94025813-8bb7b300-fd7e-11ea-94b3-411badfbd318.png) If these values matter: `pwsh --version`: PowerShell 7.0.2 `$PSVersionTable`: |Key |Value | |-------------------------|----------------------------| |PSEdition |Core | |PSCompatibleVersions |System.Version[] | |Platform |Win32NT | |GitCommitId |7.0.2 | |OS |Microsoft Windows 10.0.18363| |PSVersion |7.0.2 | |PSRemotingProtocolVersion|2.3 | |SerializationVersion |1.1.0.1 | |WSManStackVersion |3.0 |
Author
Owner

@markashleybell commented on GitHub (Oct 8, 2020):

I'm not sure if this is useful, but I was also seeing this issue until I deleted the saved connection settings (r) and re-authenticated. I then saw a much more useful message, which led me to the actual cause:

image

@markashleybell commented on GitHub (Oct 8, 2020): I'm not sure if this is useful, but I was also seeing this issue _until_ I deleted the saved connection settings (`r`) and re-authenticated. I then saw a much more useful message, which led me to the actual cause: ![image](https://user-images.githubusercontent.com/483470/95451499-c5ccab80-095f-11eb-8527-636cf3af3d7d.png)
Author
Owner

@jamesdecourcy commented on GitHub (Oct 13, 2020):

I had the same problem. Going to https://shell.azure.com AND THEN changing from Bash to PowerShell. This seemed to set everything up so it now works when I log in via Windows Terminal.

@jamesdecourcy commented on GitHub (Oct 13, 2020): I had the same problem. Going to https://shell.azure.com AND THEN changing from Bash to PowerShell. This seemed to set everything up so it now works when I log in via Windows Terminal.
Author
Owner

@csijake commented on GitHub (Oct 13, 2020):

Wow! @jamesdecourcy That solved the issue for me!

This is a really bad error message with an even stranger fix (changing a preference in a web browser affects a terminal instance in Windows!?). What is the best resolution here?

  1. Make the error message better with clear instructions, or an aka.ms link on how to troubleshoot / fix?
  2. Prompt and allow the user to switch their preference via the terminal from Bash to PowerShell?
  3. Something else?
@csijake commented on GitHub (Oct 13, 2020): Wow! @jamesdecourcy That solved the issue for me! This is a really bad error message with an even stranger fix (changing a preference in a web browser affects a terminal instance in Windows!?). What is the best resolution here? 1. Make the error message better with clear instructions, or an aka.ms link on how to troubleshoot / fix? 2. Prompt and allow the user to switch their preference via the terminal from Bash to PowerShell? 3. Something else?
Author
Owner

@wbpluto commented on GitHub (Nov 8, 2020):

Likely due to the shell storage hasn't been setup yet. Login to your Azure Portal, select the Azure Shell on top to first initialize and setup the shell. Once the storage is completed, you should be able connect via Azure Cloud Shell.

Yes, I know this helps. But why we cannot do this in Windows Terminal or give us a more clear message.

@wbpluto commented on GitHub (Nov 8, 2020): > Likely due to the shell storage hasn't been setup yet. Login to your Azure Portal, select the Azure Shell on top to first initialize and setup the shell. Once the storage is completed, you should be able connect via Azure Cloud Shell. Yes, I know this helps. But why we cannot do this in Windows Terminal or give us a more clear message.
Author
Owner

@Don-Vito commented on GitHub (Nov 8, 2020):

@wbpluto - I have implemented a fix but was able to test it only once. Since I fixed the issue in azure portal by selecting a shell, I cannot reproduce the issue anymore. Even if I remove the user settings with an API or for new subscriptions.

My guess is that the problem happens only for "old" cloud shells, i.e., for those configured by an old versions of cloud console API (with API version lower than 2018-10-1). In such case, settings lack a "preferredShellType" field, that Terminal expects. As a result for such shells, Terminal succeeds to fetch the configuration, but then crashes trying to read this missing field.

I have added a code that prevents a crash and instead suggests to login in the browser and to set the shell.
I will try to push the code and let's see if the team likes it 😊

@Don-Vito commented on GitHub (Nov 8, 2020): @wbpluto - I have implemented a fix but was able to test it only once. Since I fixed the issue in azure portal by selecting a shell, I cannot reproduce the issue anymore. Even if I remove the user settings with an API or for new subscriptions. My guess is that the problem happens only for "old" cloud shells, i.e., for those configured by an old versions of cloud console API (with API version lower than 2018-10-1). In such case, settings lack a "preferredShellType" field, that Terminal expects. As a result for such shells, Terminal succeeds to fetch the configuration, but then crashes trying to read this missing field. I have added a code that prevents a crash and instead suggests to login in the browser and to set the shell. I will try to push the code and let's see if the team likes it :blush:
Author
Owner

@wbpluto commented on GitHub (Nov 10, 2020):

@wbpluto - I have implemented a fix but was able to test it only once. Since I fixed the issue in azure portal by selecting a shell, I cannot reproduce the issue anymore. Even if I remove the user settings with an API or for new subscriptions.

My guess is that the problem happens only for "old" cloud shells, i.e., for those configured by an old versions of cloud console API (with API version lower than 2018-10-1). In such case, settings lack a "preferredShellType" field, that Terminal expects. As a result for such shells, Terminal succeeds to fetch the configuration, but then crashes trying to read this missing field.

I have added a code that prevents a crash and instead suggests to login in the browser and to set the shell.
I will try to push the code and let's see if the team likes it 😊

Thanks, so clear! Can you tell me how can I delete of get the Cloud Shell user setting with API or CLI?

@wbpluto commented on GitHub (Nov 10, 2020): > @wbpluto - I have implemented a fix but was able to test it only once. Since I fixed the issue in azure portal by selecting a shell, I cannot reproduce the issue anymore. Even if I remove the user settings with an API or for new subscriptions. > > My guess is that the problem happens only for "old" cloud shells, i.e., for those configured by an old versions of cloud console API (with API version lower than 2018-10-1). In such case, settings lack a "preferredShellType" field, that Terminal expects. As a result for such shells, Terminal succeeds to fetch the configuration, but then crashes trying to read this missing field. > > I have added a code that prevents a crash and instead suggests to login in the browser and to set the shell. > I will try to push the code and let's see if the team likes it 😊 Thanks, so clear! Can you tell me how can I delete of get the Cloud Shell user setting with API or CLI?
Author
Owner

@Don-Vito commented on GitHub (Nov 10, 2020):

@wbpluto - after some work with the team, what we pushed was to fallback to powershell if "preferredShell" cannot be loaded.

The settings can be retrieved this way:

$token= ((Invoke-WebRequest -Uri "$env:MSI_ENDPOINT`?resource=https://management.core.windows.net/" -Headers @{Metadata='true'}).content |  ConvertFrom-Json).access_token
((Invoke-WebRequest -Uri https://management.azure.com/providers/Microsoft.Portal/usersettings/cloudconsole?api-version=2018-10-01 -Headers @{Authorization = "Bearer $token"}).Content | ConvertFrom-Json).properties | Format-List

and deleted this way:

$token= ((Invoke-WebRequest -Uri "$env:MSI_ENDPOINT`?resource=https://management.core.windows.net/" -Headers @{Metadata='true'}).content |  ConvertFrom-Json).access_token
Invoke-WebRequest -Method Delete -Uri https://management.azure.com/providers/Microsoft.Portal/usersettings/cloudconsole?api-version=2018-10-01 -Headers @{Authorization = "Bearer $token"}
@Don-Vito commented on GitHub (Nov 10, 2020): @wbpluto - after some work with the team, what we pushed was to fallback to powershell if "preferredShell" cannot be loaded. The settings can be retrieved this way: ``` $token= ((Invoke-WebRequest -Uri "$env:MSI_ENDPOINT`?resource=https://management.core.windows.net/" -Headers @{Metadata='true'}).content | ConvertFrom-Json).access_token ((Invoke-WebRequest -Uri https://management.azure.com/providers/Microsoft.Portal/usersettings/cloudconsole?api-version=2018-10-01 -Headers @{Authorization = "Bearer $token"}).Content | ConvertFrom-Json).properties | Format-List ``` and deleted this way: ``` $token= ((Invoke-WebRequest -Uri "$env:MSI_ENDPOINT`?resource=https://management.core.windows.net/" -Headers @{Metadata='true'}).content | ConvertFrom-Json).access_token Invoke-WebRequest -Method Delete -Uri https://management.azure.com/providers/Microsoft.Portal/usersettings/cloudconsole?api-version=2018-10-01 -Headers @{Authorization = "Bearer $token"} ```
Author
Owner

@ghost commented on GitHub (Nov 11, 2020):

:tada:This issue was addressed in #8197, which has now been successfully released as Windows Terminal Preview v1.5.3142.0.🎉

Handy links:

@ghost commented on GitHub (Nov 11, 2020): :tada:This issue was addressed in #8197, which has now been successfully released as `Windows Terminal Preview v1.5.3142.0`.:tada: Handy links: * [Release Notes](https://github.com/microsoft/terminal/releases/tag/v1.5.3142.0) * [Store Download](https://www.microsoft.com/store/apps/9n8g5rfz9xk3?cid=storebadge&ocid=badge)
Author
Owner

@ChadLevy commented on GitHub (Dec 7, 2020):

I had the same problem. Going to shell.azure.com AND THEN changing from Bash to PowerShell. This seemed to set everything up so it now works when I log in via Windows Terminal.

image

I had the same problem as well (obscure error message) and went to the same URL and was alerted that I needed to setup a storage account. After doing so (it was automatically handled by the site - just needed to specify which subscription) I was presented with the option to switch between Bash or PS.

Before selecting the option, I tried the cloud shell again and received a useful message:

You have not set up your cloud shell account yet. Please go to https://shell.azure.com to set it up.

After selecting Powershell in the browser, I tried again in Terminal and it's working as expected.

@ChadLevy commented on GitHub (Dec 7, 2020): > I had the same problem. Going to [shell.azure.com](https://shell.azure.com) AND THEN changing from Bash to PowerShell. This seemed to set everything up so it now works when I log in via Windows Terminal. ![image](https://user-images.githubusercontent.com/909190/101399147-ad600b00-3894-11eb-9dec-ea15c6894069.png) I had the same problem as well (obscure error message) and went to the same URL and was alerted that I needed to setup a storage account. After doing so (it was automatically handled by the site - just needed to specify which subscription) I was presented with the option to switch between Bash or PS. Before selecting the option, I tried the cloud shell again and received a useful message: > You have not set up your cloud shell account yet. Please go to https://shell.azure.com to set it up. After selecting Powershell in the browser, I tried again in Terminal and it's working as expected.
Author
Owner

@Don-Vito commented on GitHub (Dec 7, 2020):

@ChadLevy - what version of the terminal are you using? We don't expect this error in the new builds.

@Don-Vito commented on GitHub (Dec 7, 2020): @ChadLevy - what version of the terminal are you using? We don't expect this error in the new builds.
Author
Owner

@ChadLevy commented on GitHub (Dec 7, 2020):

@Don-Vito

1.4.3243.0

@ChadLevy commented on GitHub (Dec 7, 2020): @Don-Vito 1.4.3243.0
Author
Owner

@Don-Vito commented on GitHub (Dec 7, 2020):

@Don-Vito

1.4.3243.0

@ChadLevy - Thanks! I was worried for a moment. The fix was introduced in 1.5.3142.0 (which is still in preview) and it will fallback to powershell without a need to go to shell.azure.com.

@Don-Vito commented on GitHub (Dec 7, 2020): > > > @Don-Vito > > 1.4.3243.0 @ChadLevy - Thanks! I was worried for a moment. The fix was introduced in 1.5.3142.0 (which is still in preview) and it will fallback to powershell without a need to go to shell.azure.com.
Author
Owner

@homotechsual commented on GitHub (Nov 4, 2022):

I reproduced this error on 1.16.2642.0 has the fix been reverted?

@homotechsual commented on GitHub (Nov 4, 2022): I reproduced this error on 1.16.2642.0 has the fix been reverted?
Author
Owner

@zadjii-msft commented on GitHub (Nov 4, 2022):

has the fix been reverted

I don't believe there have been any meaningful changes to the azure cloud shell for some time now. You may want to file a new issue to track whatever you're seeing, as this thread is a couple years out of date now.

@zadjii-msft commented on GitHub (Nov 4, 2022): > has the fix been reverted I don't believe there have been any meaningful changes to the azure cloud shell for some time now. You may want to file a new issue to track whatever you're seeing, as this thread is a couple years out of date now.
Author
Owner

@coujean99 commented on GitHub (Dec 2, 2022):

Same problem here...
image

@coujean99 commented on GitHub (Dec 2, 2022): Same problem here... ![image](https://user-images.githubusercontent.com/54377330/205214653-23c0e04d-cfd8-415e-8709-018acc43ca01.png)
Author
Owner

@kororo211 commented on GitHub (Sep 26, 2023):

same issue with version 1.16.2642.0, any idea?

@kororo211 commented on GitHub (Sep 26, 2023): same issue with version 1.16.2642.0, any idea?
Author
Owner

@dave-007 commented on GitHub (Oct 3, 2023):

same issue with version 1.16.2642.0, any idea?

Same, started happening started within last week, can't use Windows Terminal to access Azure Cloud Shell.

This is with a Microsoft account using an Azure pass sponsorship.
Things I've done:

  • Connected to cloud shell via browser in the portal and shell.azure.com successfully
  • run az provider register -n Microsoft.CloudShell and verified it installed via az provider show -n Microsoft.CloudShell
    (The warning instructions to register Microsoft.CloudShell persist.
  • Verified I only have access to single tenant and single subscription, this is supported by az account show

image

@dave-007 commented on GitHub (Oct 3, 2023): > same issue with version 1.16.2642.0, any idea? Same, started happening started within last week, can't use Windows Terminal to access Azure Cloud Shell. This is with a Microsoft account using an Azure pass sponsorship. Things I've done: - Connected to cloud shell via browser in the portal and shell.azure.com successfully - run `az provider register -n Microsoft.CloudShell ` and verified it installed via ` az provider show -n Microsoft.CloudShell ` (The warning instructions to register Microsoft.CloudShell persist. - Verified I only have access to single tenant and single subscription, this is supported by ` az account show` ![image](https://github.com/microsoft/terminal/assets/240789/2781ea6c-510a-4fbe-87ed-69afe8be6b8b)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#9823