question

GohSokBoon-9189 avatar image
0 Votes"
GohSokBoon-9189 asked YutongTie-MSFT commented

Unable to deploy a ML Model

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
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for reaching out to us. This is a known issue which should be fix on Sep. I am sorry to hear this happened to you again. Checking with product group to see.

Regards,
Yutong

0 Votes 0 ·
YutongTie-MSFT avatar image
0 Votes"
YutongTie-MSFT answered

@GohSokBoon-9189

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







5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

YutongTie-MSFT avatar image
0 Votes"
YutongTie-MSFT answered GohSokBoon-9189 commented

@GohSokBoon-9189

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

· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi, I still encountered same error below. I attached the error log.140534-python-error.txt


1 Vote 1 ·
python-error.txt (6.0 KiB)
YutongTie-MSFT avatar image
0 Votes"
YutongTie-MSFT answered YutongTie-MSFT commented

@GohSokBoon-9189

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 Docs
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 Docs
InteractiveLoginAuthentication like
azureml.core.authentication.InteractiveLoginAuthentication class - Azure Machine Learning Python | Microsoft Docs
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

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi Yutong,

I still encountered same error "message": "Could not retrieve user token. Please run 'az login'" when you use your workaround. I am still using python 3.9.

0 Votes 0 ·

@GohSokBoon-9189 Sorry to hear your experience. I will highly recommend you to raise a support ticket for this issue if you have a support plan. If you don't have one, please let me know, I can enable you a one-time-free ticket for this situation.

Regards,
Yutong

0 Votes 0 ·