converting dynamic content to JSON

Koen Verschuren 31 Reputation points
2022-06-23T17:11:41.037+00:00

I'm building a pipeline who sends a secret to the rest API of Azure key-vault with the Azure data factory tool (https://learn.microsoft.com/en-us/rest/api/keyvault/secrets/set-secret/set-secret). If I set the secret hardcoded then it works fine but if I replace it with my dynamic content variable it gives a newline error. Does anyone has a solution for this problem?

214465-cbrza.png

The working code:
{
"values": "test"
}

the not working code:
{
"values": @variables('push_refresh_token')
}

Azure Key Vault
Azure Key Vault
An Azure service that is used to manage and protect cryptographic keys and other secrets used by cloud apps and services.
1,372 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,245 questions
0 comments No comments
{count} votes

Accepted answer
  1. AnnuKumari-MSFT 34,011 Reputation points Microsoft Employee
    2022-06-24T08:53:30.49+00:00

    Hi anonymous user-6858 ,

    Welcome to Microsoft Q&A platform and thanks for posting your query.
    It seems you are trying to set secret using ADF pipeline, but are getting error . Please let me know if my understanding is incorrect.

    Kindly use the below expression to replace '\r\n' with empty string to mitigate the issue: @replace(string(variables('push_refresh_token')),'\r\n','')

    Hope this will help. Please let us know if any further queries.

    ------------------------------

    • Please don't forget to click on 130616-image.png or upvote 130671-image.png button whenever the information provided helps you.
      Original posters help the community find answers faster by identifying the correct answer. Here is how
    • Want a reminder to come back and check responses? Here is how to subscribe to a notification
    • If you are interested in joining the VM program and help shape the future of Q&A: Here is how you can be part of Q&A Volunteer Moderators

1 additional answer

Sort by: Most helpful
  1. Koen Verschuren 31 Reputation points
    2022-06-24T17:23:57.047+00:00

    the final solution was adding quotes to the variable with concatenate

    set variable:
    @markus.bohland@hotmail.de ('"', string(activity('get_auth_code').output.refresh_token),'"')

    followed by:
    web:
    @markus.bohland@hotmail.de ('{"value":', variables('push_refresh_token'),'}')

    1 person found this answer helpful.
    0 comments No comments

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.