
Answer-first summary for fast verification
Answer: Yes
The solution meets the goal because it correctly uses the Workspace constructor with the specific subscription ID ('sub2'), resource group ('rg-ml-project'), and workspace name ('ml-project') to obtain a reference to the ml-project workspace. This method directly authenticates and retrieves the workspace without relying on a config.json file, which is the purpose of the Workspace constructor. The community discussion shows confusion between Workspace.from_config() (which requires a config file) and the Workspace constructor used here, but the provided code uses the constructor with explicit parameters, making it valid. The high upvotes on comments supporting 'A' and the official Microsoft documentation confirm that this approach is correct for programmatically accessing a workspace with known details.
Author: LeetQuiz Editorial Team
Ultimate access to all questions.
You have the following Azure subscriptions and Azure Machine Learning service workspaces:
ml-prod in resource group rg-ml-prodml-project in resource group rg-ml-projectYou need to obtain a reference to the ml-project workspace.
Solution: Run the following Python code:
from azureml.core import Workspace
ws = Workspace(subscription_id="sub2",
resource_group="rg-ml-project",
workspace_name="ml-project")
from azureml.core import Workspace
ws = Workspace(subscription_id="sub2",
resource_group="rg-ml-project",
workspace_name="ml-project")
Does the solution meet the goal?

A
Yes
B
No
No comments yet.