From 59fa630da714cc143a139e8fe8a43eb7ea4a1c3f Mon Sep 17 00:00:00 2001 From: Kirill Komissarov Date: Fri, 3 Oct 2025 01:10:00 -0700 Subject: [PATCH] fix: use Azure CLI by default for capturing test recordings --- azure-quantum/tests/README.md | 18 +++++++----------- azure-quantum/tests/unit/common.py | 4 ++-- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/azure-quantum/tests/README.md b/azure-quantum/tests/README.md index 482fc3af..f999bfdb 100644 --- a/azure-quantum/tests/README.md +++ b/azure-quantum/tests/README.md @@ -17,22 +17,18 @@ AZURE_TEST_RUN_LIVE="True" This will force the recording files to be deleted before running the tests. -To be able to run the tests in recording or live mode, make sure: - -- You have a client app registered in Microsoft Entra ID (formerly Azure Active Directory) -- The client app is configured with [certificate-based authentication](https://learn.microsoft.com/en-us/entra/identity/authentication/how-to-certificate-based-authentication) -- The client app has "Contributor" permissions to your Azure Quantum Workspace -- The following environment variables are set: - - `AZURE_CLIENT_ID` - application (client) ID from Microsoft Entra ID - - `AZURE_TENANT_ID` - directory (tenant) ID from Microsoft Entra ID - - `AZURE_CLIENT_CERTIFICATE_PATH` - path to PEM or PKCS12 certificate file (including the private key) that is configured for the client app - - `AZURE_CLIENT_SEND_CERTIFICATE_CHAIN=True` - prompts Azure.Identity to set X5C header (specifying certificate chain) required to support SNI authentication +To run the tests in recording or live mode, make sure: + +- You have installed [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest). +- You're logged into your Azure Entra ID Tenant in the Azure CLI - `az login` (or `az login --tenant `). +- You have "Quantum Workspace Owner" or "Quantum Workspace Data Contributor" or "Contributor" role on the Azure Quantum Workspace against which you would like to capture the recordings. +- You have all necessary Providers added to the Azure Quantum Workspace. +- The following environment variables are set: - `AZURE_QUANTUM_SUBSCRIPTION_ID` - ID of the Subscription where Azure Quantum Workspace is deployed - `AZURE_QUANTUM_WORKSPACE_RG` - name of the Resource Group where Azure Quantum Workspace is deployed - `AZURE_QUANTUM_WORKSPACE_NAME` - name of the Azure Quantum Workspace - `AZURE_QUANTUM_WORKSPACE_LOCATION` - Azure region where the Azure Quantum Workspace is deployed - ## Recordings Our testing infrastructure uses Python VCR to record HTTP calls against a live service and then use diff --git a/azure-quantum/tests/unit/common.py b/azure-quantum/tests/unit/common.py index 9330012f..4e7a79c7 100644 --- a/azure-quantum/tests/unit/common.py +++ b/azure-quantum/tests/unit/common.py @@ -26,7 +26,7 @@ ) from azure.quantum import Job from azure.quantum.target import Target -from azure.identity import ClientSecretCredential +from azure.identity import ClientSecretCredential, AzureCliCredential ZERO_UID = "00000000-0000-0000-0000-000000000000" @@ -304,7 +304,7 @@ def create_workspace( client_secret=PLACEHOLDER) workspace = Workspace( - credential=credential, + credential=credential if credential else AzureCliCredential(), subscription_id=connection_params.subscription_id, resource_group=connection_params.resource_group, name=connection_params.workspace_name,