問題を再現できます。この行ds_ls ="AzureBlobStorage"
は間違っていますds_ls = LinkedServiceReference(reference_name=ls_name)
。
私の完全な作業サンプルを参照できます。
サービス プリンシパルがデータ ファクトリの RBAC ロール (例: )を持ちOwner
、すべての前提条件を満たしていることを確認してください。Contributor
Access control (IAM)
私のパッケージバージョン:
azure-mgmt-datafactory 0.6.0
azure-mgmt-resource 3.1.0
azure-common 1.1.23
コード:
from azure.common.credentials import ServicePrincipalCredentials
from azure.mgmt.resource import ResourceManagementClient
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.mgmt.datafactory.models import *
subscription_id = '<subscription-id>'
ls_name = 'storageLinkedService'
rg_name = '<group-name>'
df_name = '<datafactory-name>'
credentials = ServicePrincipalCredentials(client_id='<client id of the service principal>',
secret='<secret of the service principal>', tenant='<tenant-id>')
resource_client = ResourceManagementClient(credentials, subscription_id)
adf_client = DataFactoryManagementClient(credentials, subscription_id)
storage_string = SecureString('DefaultEndpointsProtocol=https;AccountName=<storage account name>;AccountKey=<storage account key>')
ls_azure_storage = AzureStorageLinkedService(connection_string=storage_string)
ls = adf_client.linked_services.create_or_update(rg_name, df_name, ls_name, ls_azure_storage)
ds_ls = LinkedServiceReference(reference_name=ls_name)
# Create an Azure blob dataset (output)
dsOut_name = 'ds_out'
output_blobpath = '<container name>/<folder name>'
dsOut_azure_blob = AzureBlobDataset(linked_service_name=ds_ls, folder_path=output_blobpath)
dsOut = adf_client.datasets.create_or_update(rg_name, df_name, dsOut_name, dsOut_azure_blob)
print(dsOut)