Skip to content
This repository was archived by the owner on Jun 11, 2026. It is now read-only.
This repository was archived by the owner on Jun 11, 2026. It is now read-only.

import Workspace in Azure ML #5

@kyoro1

Description

@kyoro1

I found that there're some options about the setting of Workspace in Azure ML in /src/utils.py script, and they're ordered sequentially. Indeed, they consist of 3 steps with try - except structure:

  1. Induce from run object
    try:
        run = Run.get_context()
        if not isinstance(run, _OfflineRun):
            ws = run.experiment.workspace
            return ws
    except Exception as ex:
        print('Workspace from run not found', ex)
  1. Retrieve config file with .from_config() method
    try:
        ws = Workspace.from_config()
        return ws
    except Exception as ex:
        print('Workspace config not found in local folder', ex)
  1. Pre-defined subscription & Service principal
    try:
        sp = ServicePrincipalAuthentication(
            tenant_id=os.environ['AML_TENANT_ID'],
            service_principal_id=os.environ['AML_PRINCIPAL_ID'],
            service_principal_password=os.environ['AML_PRINCIPAL_PASS']
        )
        ws = Workspace.get(
            name="<ml-example>",
            auth=sp,
            subscription_id="<your-sub-id>"
        )
    except Exception as ex:
        print('Workspace config not found in project', ex)

Imagine that an user wants to use option 3(Service principal), and he/she receives errors for both options 1/2. Then, is it better to modify the structure of try - except?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions