What I'm trying to do
I'm trying to create an azure data factory pipeline to copy and paste file from a blob to a blob or from a blob to a data lake.
What i did
I just followed the tutorial on Microsoft's website, i already have an ADF and blob so i didn't create it again, i'm now trying to create an Azure linked service, so i used this code:
# Create an Azure Storage linked service
ls_name = 'storageLinkedService'
# IMPORTANT: specify the name and key of your Azure Storage account.
storage_string = SecureString('DefaultEndpointsProtocol=https;AccountName=<storageaccountname>;AccountKey=<storageaccountkey>')
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)
print_item(ls)
But when i run it, i obtain this error:
Traceback (most recent call last):
File "<ipython-input-173-cabc65dd11b9>", line 4, in <module>
ls = adf_client.linked_services.create_or_update(rg_name, df_name, ls_name, ls_azure_storage)
File "C:\ProgramData\Anaconda3\lib\site-packages\azure\mgmt\datafactory\operations\linked_services_operations.py", line 170, in create_or_update
raise models.ErrorResponseException(self._deserialize, response)
ErrorResponseException: Operation returned an invalid status code 'Not Found'
I don't know why do i get this error. Does anyone have an idea ?
Update
I tried to skip this step and tried to create and file in the blob with this command: adf_client.datasets.create_or_update(rg_name, df_name, ds_name, ds_azure_blob)
I got the same error ErrorResponseException: Operation returned an invalid status code 'Not Found'
which lead me to think that the problem is related to the blob maybe.
I tried to reproduce your issue but failed.
I do not have an ADF so I followed the official tutorial to create Data Factory and Linked service, no error occurred.
main function
def main():
# Azure subscription ID
subscription_id = '***'
# This program creates this resource group. If it's an existing resource group, comment out the code that creates the resource group
rg_name = '***'
# The data factory name. It must be globally unique.
df_name = '***'
# Specify your Active Directory client ID, client secret, and tenant ID
credentials = ServicePrincipalCredentials(client_id='***', secret='***', tenant='***')
resource_client = ResourceManagementClient(credentials, subscription_id)
adf_client = DataFactoryManagementClient(credentials, subscription_id)
rg_params = {'location':'eastus'}
df_params = {'location':'eastus'}
# create the resource group
# comment out if the resource group already exits
resource_client.resource_groups.create_or_update(rg_name, rg_params)
Create a data factory
df_resource = Factory(location='eastus')
df = adf_client.factories.create_or_update(rg_name, df_name, df_resource)
print_item(df)
while df.provisioning_state != 'Succeeded':
df = adf_client.factories.get(rg_name, df_name)
time.sleep(1)
# Create an Azure Storage linked service
ls_name = 'storageLinkedService'
# IMPORTANT: specify the name and key of your Azure Storage account.
storage_string = SecureString('DefaultEndpointsProtocol=https;AccountName=***;AccountKey=***')
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)
print_item(ls)
ErrorResponseException: Operation returned an invalid status code 'Not Found'
I think you could check the arguments if you have a mistake in it or if the service exists.(df,resource group, storage account)
Any concern ,please feel free to let me know.
Update Answer:
I created my own application registration in Azure AD on portal.
Application ID as below is your client_id
Create your secret
and remember to write it down because it will hide later.
Directory Id as below is tenant ID
Update Answer 2:
I'm also a contributor role, so I think it's not a role issue. I tried to change the ra_name(resource group) in the parameter to a nonexistent value, reproduced your exception successfully .
Please check again if your resource group or other parameters exist.
Just for summary:
It seems that ADF V1 and V2 does not support West Europe Region currently.
However , the Supported regions chapters in this article have not been updated. That bothers you so long. You could re-create ADF and follow your original code to create link service.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.