NameError: name 'load_workspace_from_config' is not defined

Muqaddas Abbas 1 Reputation point
2022-05-05T19:04:03.857+00:00

i simply want to get the datastore name from my azure workspace so I can use it in databricks. i found this code
import azureml.core
from azureml.core import Workspace, Datastore

ws = load_workspace_from_config(path="config.json")
ds = get_default_datastore(ws)
print(ds)

I am facing error on this that
NameError: name 'load_workspace_from_config' is not defined

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

1 answer

Sort by: Most helpful
  1. romungi-MSFT 46,746 Reputation points Microsoft Employee
    2022-05-06T06:00:33.793+00:00

    @Muqaddas Abbas In this case you will have to use Workspace.from_config() This call will then prompt an interactive login to Azure portal.

    Ex:

       ws = Workspace.from_config()  
       ws.get_details()  
    

    Before calling this you will have to specify the config file path with details of your subscription and workspace.

       ws.write_config(path="./file-path", file_name="ws_config.json")  
    

    The JSON file should contain details of your subscription, resource group and workspace.

    {  
        "subscription_id": "<subscription-id>",  
        "resource_group": "<resource-group>",  
        "workspace_name": "<workspace-name>"  
    }  
    

    Please refer the documentation for more details.

    If an answer is helpful, please click on 130616-image.png or upvote 130671-image.png which might help other community members reading this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.