azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Set-AzureRmDataFactoryV2LinkedService : HTTP Status Code: BadRequest

Open datasharkNL opened this issue 6 years ago • 7 comments

Hi all,

When I would to deploy a Azure Data Lake Gen2 Linkedservice via powershell, i get this error:

Set-AzureRmDataFactoryV2LinkedService : HTTP Status Code: BadRequest
Error Code: BadRequest
Error Message: Failed to encrypt sub-resource payload {
  "Id": "/subscriptions/448f5935-d30a-4dac-98ef-fc1f2c2b264c/resourceGroups/TrialDS/providers/Microsoft.DataFactory/factories/TrialDS-Factory2/linkedservi
ces/LinkedServiceCuratedWikiData",
  "Name": "LinkedServiceCuratedWikiData",
  "Properties": {
    "type": "LinkedService",
    "typeProperties": {
      "url": "********************"
    },
    "annotations": []
  }
} and error is: Invalid type 'LinkedService' is provided in 'linkedServices'. Please correct the type in payload and retry..
Request Id: fe6d2d14-ae5a-41b9-a284-2dec89d78927
Timestamp (Utc):02/07/2020 15:38:03
At line:1 char:1
+ Set-AzureRmDataFactoryV2LinkedService -ResourceGroupName "TrialDS" -D ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Set-AzureRmDataFactoryV2LinkedService], ErrorResponseException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.DataFactoryV2.SetAzureDataFactoryLinkedServiceCommand

My line in powershell (copied from the tutorial): Set-AzureRmDataFactoryV2LinkedService -ResourceGroupName "TrialDS" -DataFactoryName "TrialDS-Factory2" -Name "LinkedServiceCuratedWikiData" -File "C:\\Users\\<username>\\Desktop\\ADF Deployment\\linkedservice\\datalake.json" | Format-List

But I follow this tutorial: https://docs.microsoft.com/en-us/powershell/module/azurerm.datafactories/set-azurermdatafactoryv2linkedservice?view=azurermps-4.4.1

And use the JSON of my current working ADF:

{
    "name": "datalake",
    "type": "Microsoft.DataFactory/factories/linkedservices",
    "properties": {
        "type": "AzureBlobFS",
        "typeProperties": {
            "url": "https://<mystorageaccount>.dfs.core.windows.net"
        },
        "annotations": []
    }
}

datasharkNL avatar Feb 08 '20 11:02 datasharkNL

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sumantmehtams

ghost avatar Feb 10 '20 02:02 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sumantmehtams

ghost avatar Feb 10 '20 02:02 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sumantmehtams

ghost avatar Feb 10 '20 02:02 ghost

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sumantmehtams

ghost avatar Feb 10 '20 02:02 ghost

Hi @datasharkNL thanks for your feedback. But I notice that you are using AzureRm which is almost not maintained now. Would you please migrate to Az module? The cmdlet in Az module is Set-AzDataFactoryV2LinkedService

wyunchi-ms avatar Feb 10 '20 02:02 wyunchi-ms

Hi I am facing a similar issue when I am referencing key vault secrets in the arm template.

Set-AzDataFactoryV2LinkedService : HTTP Status Code: BadRequest
Error Code: BadRequest
Error Message: Failed to encrypt sub-resource payload {
  "Id": "/subscriptions/e3798495-2d37-4c4b-b1c1-e7e48981ae45/resourceGroups/Phase1/providers/Microsoft.DataFactory/factories/raikes-testing-data-factory/linkedservices/ADLSLinkedService",
  "Name": "ADLSLinkedService",
  "Properties": {
    "type": "AzureBlobFS",
    "typeProperties": {
      "url": "********************",
      "accountKey": "********************",
      "servicePrincipalId": "********************",
      "servicePrincipalKey": "********************",
      "tenant": "********************"
    }
  }
} and error is: Failed to convert the value in 'accountKey' property to 'System.String' type. Please make sure the payload structure and value are correct..
Request Id: 31dd2eb5-c142-4b35-8c16-11f014ffb1c0

this is my json file

{
    "name": "ADLSLinkedService",
    "properties": {
        "type": "AzureBlobFS",
        "typeProperties": {
            "url": "https://unlstorage2.dfs.core.windows.net", 
            "AccountKey":  {
                "reference": {
                    "keyVault": {
                        "id": "/subscriptions/e3798495-2d37-4c4b-b1c1-e7e48981ae45/resourceGroups/Phase1/providers/Microsoft.KeyVault/vaults/raikes-devops"
                    },
                    "secretName": "ADLSAccountKey"
                }
            },            
            "servicePrincipalId":{
                "reference": {
                    "keyVault": {
                        "id": "/subscriptions/e3798495-2d37-4c4b-b1c1-e7e48981ae45/resourceGroups/Phase1/providers/Microsoft.KeyVault/vaults/raikes-devops"
                    },
                    "secretName": "ADLSPrincipalId"
                }
            },
            "servicePrincipalKey": {
                "reference": {
                    "keyVault": {
                        "id": "/subscriptions/e3798495-2d37-4c4b-b1c1-e7e48981ae45/resourceGroups/Phase1/providers/Microsoft.KeyVault/vaults/raikes-devops"
                    },
                    "secretName": "ADLSPrincipalKey"
                }
            },
            "tenant": {
                "reference": {
                    "keyVault": {
                        "id": "/subscriptions/e3798495-2d37-4c4b-b1c1-e7e48981ae45/resourceGroups/Phase1/providers/Microsoft.KeyVault/vaults/raikes-devops"
                    },
                    "secretName": "TenantId"
                }
            }
        }
    }
}

This is the powershell command I am using to create ADFLS.

Set-AzDataFactoryV2LinkedService -DataFactoryName $NewDataFactoryName -ResourceGroupName $ResourceGroupName -Name "ADLSLinkedService" -File ".\templates\ADLSLinkedService.json"

stamkiya avatar Feb 19 '20 16:02 stamkiya

:bell: Routing this issue to @act-codegen-extensibility-squad.