I am trying to execute REST API to link keyvault with variable group, when I execute below REST API command as it is executing but when I go to variable group the secrets are not saving and showing at the top
Value cannot be null. Parameter name: variableGroupParameters
Even when I want to update new secret, it is throwing the same error. Does anyone know the solution?
curl -X POST
-u :PAT_TOKEN
-H "Content-Type: application/json"
-d @kv_payload.json
"https://dev.azure.com/{org_name}/{project_name}/_apis/distributedtask/variablegroups?api-version=7.1-preview.1"
Payload
{
"name": "variablegroupname",
"type": "AzureKeyVault",
"providerData": {
"serviceEndpointId": "xxxxxxxxx",
"vault": "keyvaultname"
},
"variables": {
"storage-name": {
"value": "null",
"isSecret": true,
"contentType": "",
"enabled": true
},
"my-password": {
"value": "null",
"isSecret": true,
"contentType": "",
"enabled": true
}
},
"description": "Keyvault secrets managed by automated script"
}
2
Answers
I have also tried using the rest api, but also not work, and no error throw at my side.
Although this providerData was added, the result was not linked successfully. The property providerData comes from that I manually create-get the keyvault linked variable group, should be correct.
My thoughts:
keyvault link variable group operating on the ado UI is an interactive process. I think the logic behind this process may be more complicated and cannot be covered by a simple
providerData
property.You can link key vault to a variable group using below Rest API and request body.
Request body should be in below format-
I am able to create the variable group.