From f83771ecc2a2bf07e1db35f9b9a23904ee0976c1 Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 9 Jun 2021 07:47:30 -0700 Subject: [PATCH 1/2] fixing readme --- sdk/tables/azure-data-tables/README.md | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/sdk/tables/azure-data-tables/README.md b/sdk/tables/azure-data-tables/README.md index 373d415e0ae5..c87835db6e78 100644 --- a/sdk/tables/azure-data-tables/README.md +++ b/sdk/tables/azure-data-tables/README.md @@ -22,7 +22,7 @@ The Azure Data Tables SDK can access an Azure Storage or CosmosDB account. ### Install the package Install the Azure Data Tables client library for Python with [pip][pip_link]: ```bash -pip install --pre azure-data-tables +pip install azure-data-tables ``` #### Create the client @@ -59,8 +59,12 @@ az storage account keys list -g MyResourceGroup -n MyStorageAccount Use the key as the credential parameter to authenticate the client: ```python + from azure.core.credentials import AzureNamedKeyCredential from azure.data.tables import TableServiceClient - service = TableServiceClient(endpoint="https://.table.core.windows.net", credential="") + + credential = AzureNamedKeyCredential("my_account_name", "my_access_key") + + service = TableServiceClient(endpoint="https://.table.core.windows.net", credential=credential) ``` ##### Creating the client from a connection string @@ -84,16 +88,17 @@ To use a [shared access signature (SAS) token][azure_sas_token], provide the tok ```python from datetime import datetime, timedelta from azure.data.tables import TableServiceClient, generate_account_sas, ResourceTypes, AccountSasPermissions + from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential + credential = AzureNamedKeyCredential("my_account_name", "my_access_key") sas_token = generate_account_sas( - account_name="", - account_key="", + credential, resource_types=ResourceTypes(service=True), permission=AccountSasPermissions(read=True), - expiry=datetime.utcnow() + timedelta(hours=1) + expiry=datetime.utcnow() + timedelta(hours=1), ) - table_service_client = TableServiceClient(endpoint="https://.table.core.windows.net", credential=sas_token) + table_service_client = TableServiceClient(endpoint="https://.table.core.windows.net", credential=AzureSasCredential(sas_token)) ``` From a6206d7f9548137eaad7fa2e372d19b8075f7c7d Mon Sep 17 00:00:00 2001 From: seankane-msft Date: Wed, 9 Jun 2021 07:50:18 -0700 Subject: [PATCH 2/2] fixed extra indentation --- sdk/tables/azure-data-tables/README.md | 40 +++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/sdk/tables/azure-data-tables/README.md b/sdk/tables/azure-data-tables/README.md index c87835db6e78..9c9f08fc69c0 100644 --- a/sdk/tables/azure-data-tables/README.md +++ b/sdk/tables/azure-data-tables/README.md @@ -59,12 +59,12 @@ az storage account keys list -g MyResourceGroup -n MyStorageAccount Use the key as the credential parameter to authenticate the client: ```python - from azure.core.credentials import AzureNamedKeyCredential - from azure.data.tables import TableServiceClient +from azure.core.credentials import AzureNamedKeyCredential +from azure.data.tables import TableServiceClient - credential = AzureNamedKeyCredential("my_account_name", "my_access_key") +credential = AzureNamedKeyCredential("my_account_name", "my_access_key") - service = TableServiceClient(endpoint="https://.table.core.windows.net", credential=credential) +service = TableServiceClient(endpoint="https://.table.core.windows.net", credential=credential) ``` ##### Creating the client from a connection string @@ -76,9 +76,9 @@ az storage account show-connection-string -g MyResourceGroup -n MyStorageAccount ``` ```python - from azure.data.tables import TableServiceClient - connection_string = "DefaultEndpointsProtocol=https;AccountName=;AccountKey=;EndpointSuffix=core.windows.net" - service = TableServiceClient.from_connection_string(conn_str=connection_string) +from azure.data.tables import TableServiceClient +connection_string = "DefaultEndpointsProtocol=https;AccountName=;AccountKey=;EndpointSuffix=core.windows.net" +service = TableServiceClient.from_connection_string(conn_str=connection_string) ``` ##### Creating the client from a SAS token @@ -86,19 +86,19 @@ To use a [shared access signature (SAS) token][azure_sas_token], provide the tok functions to create a sas token for the account or table: ```python - from datetime import datetime, timedelta - from azure.data.tables import TableServiceClient, generate_account_sas, ResourceTypes, AccountSasPermissions - from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential - - credential = AzureNamedKeyCredential("my_account_name", "my_access_key") - sas_token = generate_account_sas( - credential, - resource_types=ResourceTypes(service=True), - permission=AccountSasPermissions(read=True), - expiry=datetime.utcnow() + timedelta(hours=1), - ) - - table_service_client = TableServiceClient(endpoint="https://.table.core.windows.net", credential=AzureSasCredential(sas_token)) +from datetime import datetime, timedelta +from azure.data.tables import TableServiceClient, generate_account_sas, ResourceTypes, AccountSasPermissions +from azure.core.credentials import AzureNamedKeyCredential, AzureSasCredential + +credential = AzureNamedKeyCredential("my_account_name", "my_access_key") +sas_token = generate_account_sas( + credential, + resource_types=ResourceTypes(service=True), + permission=AccountSasPermissions(read=True), + expiry=datetime.utcnow() + timedelta(hours=1), +) + +table_service_client = TableServiceClient(endpoint="https://.table.core.windows.net", credential=AzureSasCredential(sas_token)) ```