Forum Discussion

  • The error “AADSTS160021: Application requested a user session which does not exist” typically occurs when authentication fails due to session issues. Here’s how you can resolve it:

     

    1.Sign Out & Sign Back In

    Open the Azure Portal 

    Sign out completely and close the browser.

    Clear cookies/cache or use Incognito Mode.

    Sign back in and try again.

    2.Verify Your Permissions

    Ensure your account has “Contributor” or “Owner” role on the subscription or resource group.

    Confirm that Azure Machine Learning Administrator role is assigned to you.

    Go to Azure Portal - Access control (IAM) - Check Role Assignments.

     

    3.Re-Authenticate in CLI . If Using CLI or SDK

    if you are using azure CLI

    sh

    az login --use -device-code

    then, set the correct subscription

    sh

    az account set --subscription "your sub" 

    if you are using python SDK:

    python

    from azure.identity import InteractiveBrowserCredential =InteractiveBrowserCredential()

    This will prompt you to log in vai browser

    4.Check Conditional Access Policies

    Your organization might have Conditional Access Policies blocking your authentication.

    Check with your Azure AD Admin for any restrictions related to Multi-Factor Authentication (MFA) or session timeouts.

    5.Remove Expired Sessions & Tokens

    If using Microsoft Entra ID (formerly Azure AD), go to My Sign-ins and check for any failed login attempts.

    Reset the session by running:

    sh

    az logout

    az login

     

    6.Verify Microsoft Entra ID Configuration

    Go to Azure Active Directory - Enterprise Applications

    Find “Azure Machine Learning” and ensure it’s enabled for your user.

    If using Service Principal Authentication, check the SPN permissions.

     

    7.Retry with Different Authentication Method

    If logging in via browser, try Device Code Authentication:

    sh

    az login --use -device-code

    This should solve your problem. please check typos and correct syntax if you ran into compile issues.

    All the best.

Resources