Skip to content

Commit 8feb731

Browse files
[Storage] Add managed identity support to Blob perf tests (#43286)
1 parent 9b127d6 commit 8feb731

File tree

1 file changed

+7
-5
lines changed
  • sdk/storage/azure-storage-blob/tests/perfstress_tests

1 file changed

+7
-5
lines changed

sdk/storage/azure-storage-blob/tests/perfstress_tests/_test_base.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
# Licensed under the MIT License. See License.txt in the project root for license information.
44
# --------------------------------------------------------------------------------------------
55

6+
import os
67
import uuid
78

89
from devtools_testutils.perfstress_tests import PerfStressTest
910
from azure.storage.blob import BlobServiceClient as SyncBlobServiceClient
1011
from azure.storage.blob.aio import BlobServiceClient as AsyncBlobServiceClient
11-
from azure.identity import ClientSecretCredential as SyncClientSecretCredential
12-
from azure.identity.aio import ClientSecretCredential as AsyncClientSecretCredential
12+
from azure.identity import ManagedIdentityCredential as SyncManagedIdentityCredential
13+
from azure.identity.aio import ManagedIdentityCredential as AsyncManagedIdentityCredential
1314

1415
from .key_wrapper import KeyWrapper
1516

@@ -33,10 +34,11 @@ def __init__(self, arguments):
3334
# self._client_kwargs['api_version'] = '2019-02-02' # Used only for comparison with T1 legacy tests
3435

3536
if not _ServiceTest.service_client or self.args.no_client_share:
36-
if self.args.use_entra_id:
37+
use_managed_identity = os.environ.get("AZURE_STORAGE_USE_MANAGED_IDENTITY", "false").lower() == "true"
38+
if self.args.use_entra_id or use_managed_identity:
3739
account_name = self.get_from_env("AZURE_STORAGE_ACCOUNT_NAME")
38-
sync_token_credential = self.get_credential(is_async=False)
39-
async_token_credential = self.get_credential(is_async=True)
40+
sync_token_credential = SyncManagedIdentityCredential() if use_managed_identity else self.get_credential(is_async=False)
41+
async_token_credential = AsyncManagedIdentityCredential() if use_managed_identity else self.get_credential(is_async=True)
4042

4143
# We assume these tests will only be run on the Azure public cloud for now.
4244
url = f"https://{account_name}.blob.core.windows.net"

0 commit comments

Comments
 (0)