Unable to deploy a ML Model

Goh, Sok Boon 46 Reputation points
2021-10-11T13:59:01.913+00:00

I tried to deploy my machine learning model from python (using PyCharm 2018, python 3.9).
However I encountered the following error but when I run "az login" all my subscription information is displayed.
Can anyone advise?

You have logged in. Now let us find all the subscriptions to which you have access...
Interactive authentication successfully completed.
Traceback (most recent call last):
File "C:\InstalledApps\Python39\lib\site-packages\azureml\core\authentication.py", line 1653, in _get_arm_token_with_refresh
if (_get_exp_time(access_token) - time.time()) < _TOKEN_REFRESH_THRESHOLD_SEC:
File "C:\InstalledApps\Python39\lib\site-packages\azureml\core\authentication.py", line 1720, in _get_exp_time
decode_json = jwt.decode(access_token, verify=False)
TypeError: decode() got an unexpected keyword argument 'verify'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\InstalledApps\Python39\lib\site-packages\azureml\core\authentication.py", line 276, in wrapper
return test_function(self, *args, **kwargs)
File "C:\InstalledApps\Python39\lib\site-packages\azureml\core\authentication.py", line 427, in _get_arm_token
return self._get_arm_token_using_interactive_auth()
File "C:\InstalledApps\Python39\lib\site-packages\azureml\core\authentication.py", line 521, in _get_arm_token_using_interactive_auth
arm_token = _get_arm_token_with_refresh(profile_object, cloud_type, ACCOUNT, CONFIG, SESSION,
File "C:\InstalledApps\Python39\lib\site-packages\azureml\core\authentication.py", line 1660, in _get_arm_token_with_refresh
raise AuthenticationException("Could not retrieve user token. Please run 'az login'",
azureml.exceptions._azureml_exception.AuthenticationException: AuthenticationException:
Message: Could not retrieve user token. Please run 'az login'
InnerException decode() got an unexpected keyword argument 'verify'
ErrorResponse
{
"error": {
"code": "UserError",
"inner_error": {
"code": "Authentication"
},
"message": "Could not retrieve user token. Please run 'az login'"
}
}

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,563 questions
{count} votes

3 answers

Sort by: Most helpful
  1. YutongTie-MSFT 46,406 Reputation points
    2021-10-12T03:40:26.29+00:00

    @Goh, Sok Boon

    Python SDK seems not works well with Python 3.9.

    One workaround I have seen is to create a condo environment with Python 3.8. This works well for me. Could you please have a try?

    For Python 3.9 compatibility with Python SDK issue, we will work on that and let you know any update.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you. Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators
    0 comments No comments

  2. YutongTie-MSFT 46,406 Reputation points
    2021-10-13T22:02:19.43+00:00

    @Goh, Sok Boon

    Product team just deployed a fix for this issue. Python 3.9 should work now. Please check and let us know if there is still a problem for you.

    Regards,
    Yutong


  3. YutongTie-MSFT 46,406 Reputation points
    2021-10-19T16:56:21.337+00:00

    @Goh, Sok Boon

    This is the workaround works for me.

    from azureml.core.authentication import InteractiveLoginAuthentication  
    from azureml.core.compute import ComputeTarget, AmlCompute  
    from azureml.core.compute_target import ComputeTargetException  
    import urllib  
      
    forced_interactive_auth = InteractiveLoginAuthentication(tenant_id="YOUR TENANT ID", force=True)  
    #interactive_auth = InteractiveLoginAuthentication(tenant_id="YOUR TENANT ID")  
    ws = Workspace(  
        workspace_name='YOUT WS NAME',  
        subscription_id='YOUR S ID',  
        resource_group='YOUR RESOURCE',auth=forced_interactive_auth  
    )  
    

    This issue with workspace(in(login) authentication...Here are the details.
    If we are creating a workspace in our local computer without giving tenant_id or wrong tenant_id we will get this issue.
    Please refer the links below:
    How to find your tenant ID - Azure Active Directory | Microsoft Learn
    azure - Workspace Authentication: More than one token matches the criteria - Stack Overflow

    Interactive login authentication is suitable for local experimentation on your own computer and is the default authentication model when using Azure Machine Learning SDK.
    You work for company A which is on Azure.
    You get access to company B's subscription.
    Problem is: You are associated to A's AAD in ML-Studio.
    You need to specify the tenant ID in the How to find your tenant ID - Azure Active Directory | Microsoft Learn
    InteractiveLoginAuthentication like
    azureml.core.authentication.InteractiveLoginAuthentication class - Azure Machine Learning Python | Microsoft Learn
    interactive_auth = InteractiveLoginAuthentication(tenant_id=tenant_id)

    workspace = Workspace.get(name=workspace_name,
    subscription_id=subscription_id,
    resource_group=resource_group,
    auth=interactive_auth)
    Now the important part: You need to use company B's tenant_id (I used company A's .
    Of course, this is obvious while you read it...as it is to me now :)

    Please let me know if this works or not.

    Regards,
    Yutong