Skip to content

Commit 83e29f2

Browse files
committed
fix storage
1 parent 73fabc5 commit 83e29f2

File tree

7 files changed

+11
-14
lines changed

7 files changed

+11
-14
lines changed

sdk/storage/azure-storage-blob/samples/blob_samples_authentication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def auth_default_azure_credential(self):
128128
from azure.storage.blob import BlobServiceClient
129129
blob_service_client = BlobServiceClient(
130130
account_url=self.oauth_url,
131-
credential=self.shared_access_key
131+
credential=default_credential
132132
)
133133
# [END create_blob_service_client_oauth]
134134

sdk/storage/azure-storage-file-datalake/samples/datalake_samples_service.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class DataLakeServiceSamples(object):
2929

3030
connection_string = os.environ['DATALAKE_STORAGE_CONNECTION_STRING']
3131
account_name = os.getenv('DATALAKE_STORAGE_ACCOUNT_NAME', "")
32-
account_key = os.getenv('DATALAKE_STORAGE_ACCOUNT_KEY', "")
3332

3433

3534
#--Begin DataLake Service Samples-----------------------------------------------------------------
@@ -47,14 +46,14 @@ def data_lake_service_sample(self):
4746
from azure.identity import DefaultAzureCredential
4847
token_credential = DefaultAzureCredential()
4948
datalake_service_client = DataLakeServiceClient("https://{}.dfs.core.windows.net".format(self.account_name),
50-
credential=self.account_key)
49+
credential=token_credential)
5150
# [END create_datalake_service_client_oauth]
5251

5352
# get user delegation key
5453
# [START get_user_delegation_key]
5554
from datetime import datetime, timedelta
56-
# user_delegation_key = datalake_service_client.get_user_delegation_key(datetime.utcnow(),
57-
# datetime.utcnow() + timedelta(hours=1))
55+
user_delegation_key = datalake_service_client.get_user_delegation_key(datetime.utcnow(),
56+
datetime.utcnow() + timedelta(hours=1))
5857
# [END get_user_delegation_key]
5958

6059
# Create file systems

sdk/storage/azure-storage-file-datalake/samples/datalake_samples_service_async.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727

2828
connection_string = os.environ['DATALAKE_STORAGE_CONNECTION_STRING']
2929
account_name = os.getenv('DATALAKE_STORAGE_ACCOUNT_NAME', "")
30-
account_key = os.getenv('DATALAKE_STORAGE_ACCOUNT_KEY', "")
3130

3231
#--Begin DataLake Service Samples-----------------------------------------------------------------
3332

@@ -46,16 +45,15 @@ async def main():
4645
from azure.identity.aio import DefaultAzureCredential
4746
token_credential = DefaultAzureCredential()
4847
datalake_service_client = DataLakeServiceClient("https://{}.dfs.core.windows.net".format(account_name),
49-
credential=account_key)
48+
credential=token_credential)
5049
# [END create_datalake_service_client_oauth]
5150

5251
async with datalake_service_client:
5352
# get user delegation key
5453
# [START get_user_delegation_key]
5554
from datetime import datetime, timedelta
56-
#
57-
# user_delegation_key = await datalake_service_client.get_user_delegation_key(datetime.utcnow(),
58-
# datetime.utcnow() + timedelta(hours=1))
55+
user_delegation_key = await datalake_service_client.get_user_delegation_key(datetime.utcnow(),
56+
datetime.utcnow() + timedelta(hours=1))
5957
# [END get_user_delegation_key]
6058

6159
# Create file systems

sdk/storage/azure-storage-file-share/samples/file_samples_authentication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def authentication_default_azure_credential(self):
122122
from azure.storage.fileshare import ShareServiceClient
123123
share_service_client = ShareServiceClient(
124124
account_url=self.account_url,
125-
credential=self.access_key,
125+
credential=default_credential,
126126
# When using a token credential, you MUST also specify a token_intent
127127
token_intent='backup'
128128
)

sdk/storage/azure-storage-file-share/samples/file_samples_authentication_async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ async def authentication_default_azure_credential_async(self):
121121
from azure.storage.fileshare.aio import ShareServiceClient
122122
share_service_client = ShareServiceClient(
123123
account_url=self.account_url,
124-
credential=self.access_key,
124+
credential=default_credential,
125125
# When using a token credential, you MUST also specify a token_intent
126126
token_intent='backup'
127127
)

sdk/storage/azure-storage-queue/samples/queue_samples_authentication.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def authentication_by_oauth(self):
8080
token_credential = DefaultAzureCredential()
8181
# Instantiate a QueueServiceClient using a token credential
8282
from azure.storage.queue import QueueServiceClient
83-
queue_service = QueueServiceClient(account_url=self.account_url, credential=self.access_key)
83+
queue_service = QueueServiceClient(account_url=self.account_url, credential=token_credential)
8484
# [END create_queue_service_client_oauth]
8585

8686
# Get information for the Queue Service

sdk/storage/azure-storage-queue/samples/queue_samples_authentication_async.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ async def authentication_by_oauth_async(self):
8181
token_credential = DefaultAzureCredential()
8282
# Instantiate a QueueServiceClient using a token credential
8383
from azure.storage.queue.aio import QueueServiceClient
84-
queue_service = QueueServiceClient(account_url=self.account_url, credential=self.access_key)
84+
queue_service = QueueServiceClient(account_url=self.account_url, credential=token_credential)
8585
# [END async_create_queue_service_client_oauth]
8686

8787
# Get information for the Queue Service

0 commit comments

Comments
 (0)