Working With Azure ML workspace can be more flexible with Azure ML SDK. In this section, we are going to see how to set a workspace via AzureML SDK inside Notebook. in summary how to access the config file for the Azure ML workspace will be shown, and how to set a new workspace with different resource groups will be presented.
What is Workspace
In Microsoft Azure, we have a Subscription that each person can have many subscriptions, inside each subscription, we can create multiple Resource Groups that act like a Folder. in each resource group we are able to define multiple Azure ML workspace ( Azure ML Component), each workspace contains the model, pipeline, data, compute, experiment and so forth.
To access current workspace information, Login to your Azure subscription, then your Resource Group, and then click on the Azure ML component. Click on the Download Config.json. This file contains information about the workspace such as Subscription ID, resource group, and workspace name.
Azure Notebook
Before starting to write code and train a model, we want to allocated out workspace to azuremlleila. as you can see in the below code, first you need to import the azureml library. I am using ws variable to get workspace specification from the currently available workspace using the below function(get function)
from azureml.core import Workspace
ws = Workspace.get(name='azuremlleila',
subscription_id='SUbscription',
resource_group='aifundamentalleilaetaati',
)
ws.write_config()
As you can see above my workspace in the code has been stored in variable ws, and set all to the current workspace that is azuremlleila under the aifunamentalleilaetaati resource group.
Create New Workspace
Now in another experiment, we want to use python code with help of Azure ML SDK to define a new workspace ( beside azuremlleila).
from azureml.core import Workspace
ws = Workspace.create(name='AzureMLTest',
subscription_id='Susbcription ID',
resource_group='SDKAzureML',
create_resource_group=True,
location='eastus2'
)
In this example, we are going to use a function name create under the workspace library, we need to specify the name of the workspace, subscription, resource group, location, and so forth. we are able to create a workspace in the same resource group as well.
after running this code, in our azure environment, we are able to see a new resource group with azure ml component and workspace as below
you can see a new azure ml source has been created via code and we are able to write code and train models under it.
also, watch below video to see how it works