Reputation: 1
In ADF pipeline using post method, In body i have
grant_type=client_credentials&client_id=xxxxx&client_secret=xxxxx&resource=xxxxx.net
I have to create a variable for secret and how to pass the variable for secret and how to debug the pipeline in ADF.
I have tried to add a variable for secret and passing the variable in body it is throwing a error like bad request
Upvotes: 0
Views: 219
Reputation: 11514
To achieve your requirement, first you need to generate the Bearer token for it.
Create an app registration and secret. Assign Key vault administrator role to that app like below.
Then give the below configurations in a web activity in ADF pipeline.
URL : https://login.microsoftonline.com/<tenant-id>/oauth2/token
Body : grant_type=client_credentials&client_id=<your-app-client-id>&client_secret=<your-app-client-secret>&resource=https://vault.azure.net
Headers : Content-type application/x-www-form-urlencoded
This will generate required access_token
. To update a secret value, first you need the latest secret version of the secret. For that Use another web activity with below configurations.
URL - https://<keyvault_name>.vault.azure.net/secrets/<secret_name>/?api-version=7.0
Headers : Bearer @{activity('Web3').output.access_token}
This will give keyvault URL in its id which contains current secret version and current secret value.
Now, use this id
as URL in another web activity and here pass your variable to the body with a PUT request like below to update the secret value.
URL : @concat(activity('Web1').output.id,'?api-version=7.4')
Body : @json(concat('{"value": "',variables('new_secret'),'", "contentType": "","attributes":{"enabled": true},"tags": {}}'))
Debug the pipeline and after the pipeline run, the secret value will be updated from the set variable like mine.
Upvotes: 1