diff --git a/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/PerfTestEnvironment.cs b/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/PerfTestEnvironment.cs index 5c7d9549c662..77badec8a6b9 100644 --- a/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/PerfTestEnvironment.cs +++ b/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/PerfTestEnvironment.cs @@ -33,6 +33,19 @@ internal sealed class PerfTestEnvironment : TestEnvironment /// The Blob storage account key, read from the "AZURE_STORAGE_ACCOUNT_KEY" environment variable. public string StorageAccountKey => GetOptionalVariable("AZURE_STORAGE_ACCOUNT_KEY"); + public bool StorageUseManagedIdentity + { + get + { + string useManagedIdentity = GetOptionalVariable("AZURE_STORAGE_USE_MANAGED_IDENTITY"); + if (bool.TryParse(useManagedIdentity, out bool result)) + { + return result; + } + return false; + } + } + /// /// The Blob storage endpoint. /// diff --git a/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/ServiceTest.cs b/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/ServiceTest.cs index 4a6677cda11c..4f2c5eedbe70 100644 --- a/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/ServiceTest.cs +++ b/sdk/storage/Azure.Storage.Blobs/perf/Azure.Storage.Blobs.Perf/Infrastructure/ServiceTest.cs @@ -1,6 +1,8 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using Azure.Core; +using Azure.Identity; using Azure.Test.Perf; namespace Azure.Storage.Blobs.Perf @@ -15,9 +17,13 @@ public ServiceTest(TOptions options) : base(options) BlobClientOptions clientOptions = options is Options.IBlobClientOptionsProvider clientOptionsOptions ? clientOptionsOptions.ClientOptions : new BlobClientOptions(); + // The default credential does not support managed identity + TokenCredential credential = PerfTestEnvironment.Instance.StorageUseManagedIdentity ? + new ManagedIdentityCredential(new ManagedIdentityCredentialOptions(ManagedIdentityId.SystemAssigned)) : + PerfTestEnvironment.Instance.Credential; BlobServiceClient = new BlobServiceClient( PerfTestEnvironment.Instance.StorageEndpoint, - PerfTestEnvironment.Instance.Credential, + credential, ConfigureClientOptions(clientOptions)); // Can't do shared key tests if shared key wasn't provided