Azure-docs: SecureString parameter name must be specified

Created on 6 Mar 2019  Â·  14Comments  Â·  Source: MicrosoftDocs/azure-docs

Thank you for the code! However, there is a bug as follows:

SecureString function accepts a string parameter. However, it accepts the string when passed using "value" parameter key else it throws below given error:

Example:

storage_string = SecureString('DefaultEndpointsProtocol=https;AccountName=<storage account name>;AccountKey=<storage account key>')

Error:

TypeError: __init__() takes exactly 1 argument (2 given)

python module code snippet

vi secure_string.py
self.value = kwargs.get('value', None)

Solution:

storage_string = SecureString(value='DefaultEndpointsProtocol=https;AccountName=<storage account name>;AccountKey=<storage account key>')

Also, df_params variable can be removed from the code.


Document Details

⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Pri2 assigned-to-author data-factorsvc doc-bug triaged

All 14 comments

@abhiSakhuja Thank you for the detailed feedback. This is being assigned to the content author to evaluate and update as appropriate.

this change gets the code further along, but in the block where the dataset is being created, this errors out:

Traceback (most recent call last):
  File "datafactory2.py", line 124, in <module>
    main()
  File "datafactory2.py", line 81, in main
    ds_ls = LinkedServiceReference(ls_name)
TypeError: __init__() takes 1 positional argument but 2 were given

@justinhauer You have to use LinkedServiceReference module as:

LinkedServiceReference(reference_name=ls_name)

Do any of you that put out this code actually test it? even as @abhiSakhuja has pointed out to get this piece to work, your code still doesn't run, and this is the reference material you put out for your customers.

@justinhauer I am able to fix all bugs and have a working python code. Let me know where you are stuck, so that I can share that particular part of code.

The Microsoft data factory pipeline example is broken because of this bug:

https://docs.microsoft.com/en-us/azure/data-factory/quickstart-create-data-factory-python

When configuring a DF pipeline as in the above example code:

# IMPORTANT: specify the name and key of your Azure Storage account.
    #'DefaultEndpointsProtocol=https;AccountName=<storageaccountname>;AccountKey=<storageaccountkey>'
    st_string="\'"+"DefaultEndpointsProtocol=https;AccountName="+storage_account_name+";AccountKey="+storage_account_key+"\'"
    print("DEBUG: ",st_string)
    storage_string = SecureString('DefaultEndpointsProtocol=https;AccountName=REDACTED;AccountKey=yYREDACTED==')

We get this error, even with the correct parameters:

  File "post-scripts/check-data-factory.py", line 83, in main
    storage_string = SecureString('DefaultEndpointsProtocol=https;AccountName=REDACTED;AccountKey=yYREDACTED==')
TypeError: __init__() takes exactly 1 argument (2 given)

Is there a workaround for this?

Hello @archmangler,

I have already proposed a solution to it. Try it :).

Solution:

storage_string = SecureString(value='DefaultEndpointsProtocol=https;AccountName=&lt;storage account name&gt;;AccountKey=&lt;storage account key&gt;')

Hi @abhiSakhuja - New error after applying that fix:

('DEBUG: ', "'DefaultEndpointsProtocol=https;AccountName=&lt;<REDACTED>&gt;;AccountKey=&lt;<REDACTED>&gt;'")
Traceback (most recent call last):
  File "check-data-factory.py", line 135, in <module>
    main()
  File "check-data-factory.py", line 87, in main
    ls = adf_client.linked_services.create_or_update(rg_name, data_factory_name, linked_service_name, ls_azure_storage)
  File "/home/jenkins/workspace/module-tests/blueprint/env/lib/python2.7/site-packages/azure/mgmt/datafactory/operations/linked_services_operations.py", line 175, in create_or_update
    raise exp
msrestazure.azure_exceptions.CloudError: Azure Error: BadRequest
Message: Failed to encrypt sub-resource payload {
  "Id": "/subscriptions/<REDACTED>/linkedservices/storageLinkedService",
  "Name": "storageLinkedService",
  "Properties": {
    "typeProperties": {
      "connectionString": "********************"
    },
    "type": "AzureStorage"
  }
} and error is: Expecting connection string of format "key1=value1; key2=value2"..

Given #28999, is the format still the same ?

@archmangler If you creating a linked service for storage, I would say you must be using an application (Service Principal) to do that, if yes, then you can use below given properties:

            "servicePrincipalId": "<appID>",
            "servicePrincipalKey": {
                "type": "SecureString",
                "value": "<appSecret>"
            },

Alternate Solution: Go to Azure Console > ADF > LinkedService > Create a sample storage linked service > check our the JSON format.

Is there a reason why the https://docs.microsoft.com/en-us/azure/data-factory/quickstart-create-data-factory-python example still hasn't been updated to fix the issues discussed in this thread? LinkedServiceReference is still used incorrectly in the provided script in the article, LinkedServiceReference(ls_name) instead of LinkedServiceReference(reference_name=ls_name)

reassign @linda33wj

reassign @djpmsft

Hi all,

Apologies for the delay in response. The quickstart guide has been updated and now LinkedServiceReference(reference_name=ls_name) is accurate. Please update if you are still running into any issues.

Thanks,
Daniel

sign-off

please-close

Was this page helpful?
0 / 5 - 0 ratings

Related issues

JeffLoo-ong picture JeffLoo-ong  Â·  3Comments

bdcoder2 picture bdcoder2  Â·  3Comments

JamesDLD picture JamesDLD  Â·  3Comments

AronT-TLV picture AronT-TLV  Â·  3Comments

spottedmahn picture spottedmahn  Â·  3Comments