I have been trying to create an Azure Function using the documentation. For example, here: https://docs.microsoft.com/en-us/learn/modules/develop-azure-functions/5-create-function-visual-studio-code
Every time, and with every Azure account, I can't get past the step where you sign in to your Azure account from the Azure Functions VSCode extension. This is the error I am getting:
"Selected user account does not exist in tenant 'Microsoft Learn Sandbox' and cannot access the application 'aebc6443-996d-45c2-90f0-388ff96faa56' in that tenant. The account needs to be added as an external user in the tenant first. Please use a different account."
The Microsoft Learn Sandbox error message is a red herring to me, as I am not trying to do anything with it, only with Azure Functions. The same error appears even with a completely different Azure account.
I have tried looking at several possible solutions, including switching directories (but I only have one directory, so this didn't work), changing settings in Azure AD Connect (but I don't have Azure AD Connect configured, so this didn't work), and I deleted several local .config files and directories on my machine (CentOS 7, btw). If the solution is related to my .config files, I couldn't tell which files I should actually be deleting though.
CodePudding user response:
Selected user account does not exist in tenant 'Microsoft Learn Sandbox' and cannot access the application 'aebc6443-996d-45c2-90f0-388ff96faa56' in that tenant.
Few of the workarounds you can try to sign in to Azure successfully are:
Solution 1:
Try Signing in using the CLI/PowerShell Terminals from VS Code:

1. CLI:
1. List all the subscriptions you have
az account list --output table
Name CloudName SubscriptionId State IsDefault
--------------- ------------ ---------------- --------- ----------
AssociateProd AzureCloud xxxxxxxxxxxx Enabled False
2. Pick the subscription you want and use it in the command below.
az account set --subscription <subscription_id>
az login --tenant-id <tenant-id>
Note: To get tenant-id, Go to Azure Portal > Azure Active Directory > Copy the Tenant Id.
2. PowerShell:
`Connect-AzAccount -Subscription <subscription_Name>`
or
`Connect-AzAccount -Tenant <String>`
After selecting the correct tenant/directory, you can check to see if the user does exist in that directory by going to:
Azure Active Directory -> Users -> All Users -> Search for the user
Solution 2:
As mentioned the VS developer community, this is expected behavior because something needs access to a resource in that tenant.
- If you have MFA setup, sign in to that tenant with the correct MFA.
- If you do not have any MFA setup, then remove yourself from that tenant and sign-in again.
For more information, Please follow steps provided in this Microsoft documentation.
Solution 3:
- Open VS Code > Open the Command Palette (Ctrl Shift P) > Type
Preferences: User Settingsand Click on it. - Type
Azurein the search bar, it will show the settings of Azure Resources and SelectAzure Configuration.

Include your tenant id by clicking on the Edit settings.json option or on the below box provided named as Azure:Tenant.
Save the user settings (JSON) and use Ctrl Shift P once again. Select Azure: Sign in. The authentication page loads in your browser. Sign in to your endpoint.
To test that you have successfully logged into your Azure subscription, use Ctrl Shift P and select Azure: Select Subscription and see if the subscription you have is available.
For more information, please refer this Microsoft documentation.
Note: Here your account is Microsoft Learn Sandbox, not the Work/School account. Sometimes this kind of error occurs due to endpoint set to for authorization. Please refer this SO Thread for more information on signing is different between the "Personal Microsoft" accounts and "Work/School" accounts.
