1
$\begingroup$

I'd like to submit and retrieve many Azure-quantum jobs with python scripts executed at the command line, without a Jupyter notebook.

The standard method to authenticate with Azure consists of the following sequence

from azure.quantum.qiskit import AzureQuantumProvider
provider = AzureQuantumProvider (
        resource_id = "/subscriptions/2…93c1/resourceGroups/AzureQuantum/providers/Microsoft.Quantum/Workspaces/xxx",
        location = "eastus"
    )
backend = provider.get_backend('ionq.qpu.aria-1')

The last command always triggers a unique authentication via local browser https://microsoft.com/devicelogin It takes a lot of clicking and the credentials are lost after script finishes.

Is there a way to persistently store those credentials locally to be reused by the subsequent call to azure-quantum service?

I'm looking for a solution similar to IBMQ.load_account() or MemoryCredentialStorage() working with QuantinuumAPI() Thanks Jan

$\endgroup$
1
  • $\begingroup$ Can you check if a service principle works with load_account()? $\endgroup$
    – RSW
    Oct 14, 2022 at 8:37

1 Answer 1

1
$\begingroup$

A simple way to not get prompted for credentials is to install the Azure CLI and login using az login; that will prompt once for credentials and then persist them locally in your machine so you don't have to sign in again.

Optionally, if you are using VS Code you can install the Azure Account extension and sign in there.

For all these options, the code will automatically try to discover if you've used the CLI or the extension to log in and use that. It only defaults to prompt on the browser if it can't find anything else.

There are a couple of other options that you can use to provide the credentials, like environment variables or Managed Identity. They are documented at: https://learn.microsoft.com/en-us/azure/developer/python/sdk/authentication-overview

$\endgroup$
1
  • $\begingroup$ Thank you. Indeed, it suffice I do once az login and later Azure does not require another authentication. $\endgroup$ Oct 17, 2022 at 3:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.