Skip to content

Latest commit

 

History

History
64 lines (45 loc) · 3.04 KB

optimization-authenticate-managed-identity.md

File metadata and controls

64 lines (45 loc) · 3.04 KB
author description ms.author ms.date ms.service ms.subservice ms.topic title uid
SoniaLopezBravo
This document provides instructions on how to authenticate in your Azure Quantum workspace using a managed identity.
sonialopez
06/18/2024
azure-quantum
core
how-to
Authenticate Using a Managed Identity
microsoft.quantum.optimization.authenticate-managed-identity

How to use a managed identity to authenticate in your Azure Quantum workspace

There are several scenarios where it is unsuitable to use interactive authentication or to authenticate as a user account. For example, you may want to submit jobs from a virtual machine (VM), or from a Function App. One option is to authenticate using a service principal, another option is to configure a managed identity, which this article will explain.

Configure a managed identity

A managed identity allows an application to access other Azure resources (such as your Azure Quantum workspace) and authenticate with these resources.

To configure a managed identity:

  1. Via the Azure portal, locate the resource that you wish to give access to. This resource may be a VM, a Function App, or other application.
  2. Select the resource, and view the overview page.
  3. Under Settings, select Identity.
  4. Configure the Status setting to On.
  5. Select Save to persist your configuration and confirm the opening dialog with Yes.

Grant access to your Azure Quantum workspace

In order to allow the resource to access your Azure Quantum workspace:

  1. Navigate to your Azure Quantum workspace and select Access control (IAM) from the left-side menu.

  2. Select Add and Add role assignment.

    :::image type="content" source="media/how-to-publish-qio-job-as-azurefunction/prepare-cloud-env-3.png" alt-text="Screenshot showing how to create a new role assignment on your Azure Quantum workspace.":::

  3. On the Add role assignment page, select Contributor and select Next.

  4. On the Members tab, in Assign access to, select Managed Identity, and then select + Select members.

  5. In the Select managed identities popup, select a category from the Managed identity dropdown.

  6. Select the desired resource from the list and click Select.

  7. Select Next and then select Review and assign.

Logging in to your Azure Quantum workspace

You should now be able to use your quantum workspace from your chosen resource. For example when using your workspace from within a VM, you will no longer need to authenticate each time.

In some cases, you may also want to specify explicitly within the code to use a Managed Identity Credential:

from azure.identity import ManagedIdentityCredential

from azure.quantum import Workspace
workspace = Workspace (
    resource_id = "",
    location = "" ,
    credential=ManagedIdentityCredential()
)