%azure.connect

Summary

Connects to an Azure Quantum workspace or displays current connection status.

Description

This magic command allows for connecting to an Azure Quantum workspace as specified by the resource ID of the workspace or by a combination of subscription ID, resource group name, and workspace name.

If the connection is successful, a list of the available Q# execution targets in the Azure Quantum workspace will be displayed.

Required parameters

The Azure Quantum workspace can be identified by resource ID:

  • resourceId=<string>: The resource ID of the Azure Quantum workspace. This can be obtained from the workspace page in the Azure portal. The resourceId= prefix is optional for this parameter, as long as the resource ID is valid.

Alternatively, it can be identified by subscription ID, resource group name, and workspace name:

  • subscription=<string>: The Azure subscription ID for the Azure Quantum workspace.
  • resourceGroup=<string>: The Azure resource group name for the Azure Quantum workspace.
  • workspace=<string>: The name of the Azure Quantum workspace.

Optional parameters

  • refresh: Bypasses any saved or cached credentials when connecting to Azure.
  • storage=<string>: The connection string to the Azure storage account. Required if the specified Azure Quantum workspace was not linked to a storage account at workspace creation time.

Possible errors

  • WorkspaceNotFound: No Azure Quantum workspace was found that matches the specified criteria.
  • AuthenticationFailed: Failed to authenticate to the specified Azure Quantum workspace.

Example

Connect to an Azure Quantum workspace using its resource ID:

In []: %azure.connect "/subscriptions/.../Microsoft.Quantum/Workspaces/WORKSPACE_NAME"
Out[]: Connected to Azure Quantum workspace WORKSPACE_NAME.
        <list of Q# execution targets available in the Azure Quantum workspace>

Example

Connect to an Azure Quantum workspace using its resource ID and a storage account connection string:

In []: %azure.connect resourceId="/subscriptions/.../Microsoft.Quantum/Workspaces/WORKSPACE_NAME"
                        storage="STORAGE_ACCOUNT_CONNECTION_STRING"
Out[]: Connected to Azure Quantum workspace WORKSPACE_NAME.
        <list of Q# execution targets available in the Azure Quantum workspace>

Example

Connect to an Azure Quantum workspace using individual subscription ID, resource group name, and workspace name parameters:

In []: %azure.connect subscription="SUBSCRIPTION_ID"
                        resourceGroup="RESOURCE_GROUP_NAME"
                        workspace="WORKSPACE_NAME"
                        storage="STORAGE_ACCOUNT_CONNECTION_STRING"
Out[]: Connected to Azure Quantum workspace WORKSPACE_NAME.
        <list of Q# execution targets available in the Azure Quantum workspace>

Example

Connect to an Azure Quantum workspace and force a credential prompt using the refresh option:

In []: %azure.connect refresh "/subscriptions/.../Microsoft.Quantum/Workspaces/WORKSPACE_NAME"
Out[]: To sign in, use a web browser to open the page https://microsoft.com/devicelogin
        and enter the code [login code] to authenticate.
        Connected to Azure Quantum workspace WORKSPACE_NAME.
        <list of Q# execution targets available in the Azure Quantum workspace>

Example

Print information about the currently-connected Azure Quantum workspace:

In []: %azure.connect
Out[]: Connected to Azure Quantum workspace WORKSPACE_NAME.
        <list of Q# execution targets available in the Azure Quantum workspace>