Local and Data Science Virtual Machine (DSVM)
# Create Resource group and Workspace
from azureml.core import Workspace
ws = Workspace.create(name='vscodeml-ws',
subscription_id='SUBSCRIPTION_ID',
resource_group='vscodeml-rg',
create_resource_group=True,
location='eastus2'
)
subscription_id='SUBSCRIPTION_ID',
resource_group='vscodeml-rg',
create_resource_group=True,
location='eastus2'
)
# Write config.json file file (confg file for the environent)
# A folder .azureml will be created and the config.json file will be created into it
ws.write_config(path="./", file_name="config.json")
Create folder
.azureml
Create file
.azureml/config.js
{
"subscription_id": "SUBSCRIPTION_ID",
"resource_group": "vscode-ml-rg",
"workspace_name": "vscode-ml-ws"
}
Or from Azure ML Studio
Download config file.
# Finally load the workspace (interactive login)
ws = Workspace.from_config()
# print details
ws.get_details()
# or just print short messageprint('Ready to use Azure ML {} to work with {}'.format(azureml.core.VERSION, ws.name))
You can load a specific config.json file
ws = Workspace.from_config(path="my/path/config.json")
You can load a workspace from current run context.
Applicable if you are on a compute cluster.
# did not used it in production yet
Run.get_context().experiment.workspace
Run.get_context().experiment.workspace
References:
Set up Python development environment - Azure Machine Learning | Microsoft Learn
azureml.core.run.Run class - Azure Machine Learning Python | Microsoft Learn