@Tian Yi (XC-AD/EFB2-NA) I think you have not authenticated before this step in your notebook so the error is seen. Ideally, if you are running for the first time, try to authenticate with interactive mode and then use the subscription, resource group and workspace name. See this notebook on how you can set it up from the first two cells. To fix this issue run the below and check if it works.
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential
try:
credential = DefaultAzureCredential()
# Check if given credential can get token successfully.
credential.get_token("https://management.azure.com/.default")
except Exception as ex:
# Fall back to InteractiveBrowserCredential in case DefaultAzureCredential not work
# This will open a browser page for
credential = InteractiveBrowserCredential()
If it does not work, the other way is to use the config from JSON as mentioned in the second cell of the referenced notebook. Try downloading the config.json from your ML studio and place it in the same path as notebook and run the MLClient to pickup this file.
Download the file and use it and use it from a path as mentioned in the second cell of the referenced notebook.
ml_client = MLClient.from_config(credential=credential, path=config_path)
print(ml_client)
If this answers your query, do click Accept Answer
and Yes
for was this answer helpful. And, if you have any further query do let us know.