How to create a BlobServiceClient with Service Principle or Linked Service to a Storage Account

Shao Peng Sun 91 Reputation points
2023-04-07T12:30:07.27+00:00

I could create BlobServiceClient with storage account connection string by using the solution below, but in our synapse workspace, I only have a linked service created with service principle could connect to the storage account. So do you know how could I create the BlobServiceClient with linked service or service principle?

from azure.storage.blob import BlobServiceClient
   blob_service_client = BlobServiceClient.from_connection_string(self.connection_string)
Azure Storage
Azure Storage
Globally unique resources that provide access to data management services and serve as the parent namespace for the services.
3,529 questions
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
5,373 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Patchfox 4,176 Reputation points
    2023-04-07T13:33:22.04+00:00

    Hi Shao Peng Sun I hope I can help you with this question. If i understand you correctly, you want to use the blobserviceclient for a snypase workspace. In this case, as already described by you, the right way is to create the Azure Storage Account as a linked service. The linked service can be configured for the complete storage account or with a SAS token for a specific time and range. For more info see here: https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/data-factory/v1/data-factory-azure-blob-connector.md#linked-service-properties https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/data-factory/v1/includes/data-factory-azure-storage-linked-services.md Object Class of a LinkedService and AzureStorageLinkedService Class: https://learn.microsoft.com/en-us/azure/data-factory/quickstart-create-data-factory-python#create-a-linked-service https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.datafactory.models.linkedservice?view=azure-dotnet https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.datafactory.models.azurestoragelinkedservice?view=azure-dotnet As you can see, there is no property to ingest a BlobServiceClient.

    If the reply was helpful, please don’t forget to upvote or accept it as an answer, thank you.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.