Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,19 @@ internal sealed class PerfTestEnvironment : TestEnvironment
/// <value>The Blob storage account key, read from the "AZURE_STORAGE_ACCOUNT_KEY" environment variable.</value>
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;
}
}

/// <summary>
/// The Blob storage endpoint.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down