azure-devops-cli-extension icon indicating copy to clipboard operation
azure-devops-cli-extension copied to clipboard

[Feature Request] Variable group linked to Azure Key Vault keys

Open atbagga opened this issue 5 years ago • 19 comments

Variable group linked to Azure Key Vault keys would be a great addition as well

Originally posted by @LaurentLesle in https://github.com/Azure/azure-devops-cli-extension/issues/639#issuecomment-498039169

atbagga avatar Jul 19 '19 06:07 atbagga

For clarification - there are no documented APIs to support this and we are working with the stakeholder to get an estimate on timeline. Will keep this thread posted.

geverghe avatar Sep 30 '19 10:09 geverghe

For those blocked on this can use the az devops invoke command to automate this if required using the undocumented API (API signature can change in future).

Here is the sample command with Json Request- az devops invoke --http-method post --area distributedtask --resource variablegroups --debug --in-file .\vgroup_azure_rm.json --encoding ascii --route-parameters project=atbagga --api-version 5.0-preview

{
    "description": "vgroup description",
    "name": "vgroup1",
    "providerData": {
        "serviceEndpointId": "5763599f-0a8b-403a-a4ca-dsdsdsd4b6",
        "vault": "MyAzureKeyvaultName"
    },
    "type": "AzureKeyVault",
    "variables": {
        "VARIABLE_NAME": {
            "isSecret": true,
            "value": "",
            "enabled": true,
            "contentType": "",
            "expires": null
        }
    }
}

ServiceEndpoint Id is the AzureRm Service endpoint id which can be created using az devops service-endpoint command.

atbagga avatar Oct 09 '19 09:10 atbagga

For those blocked on this can use the az devops invoke command to automate this if required using the undocumented API (API signature can change in future).

Here is the sample command with Json Request- az devops invoke --http-method post --area distributedtask --resource variablegroups --debug --in-file .\vgroup_azure_rm.json --encoding ascii --route-parameters project=atbagga --api-version 5.0-preview

{
    "description": "vgroup description",
    "name": "vgroup1",
    "providerData": {
        "serviceEndpointId": "5763599f-0a8b-403a-a4ca-dsdsdsd4b6",
        "vault": "MyAzureKeyvaultName"
    },
    "type": "AzureKeyVault",
    "variables": {
        "VARIABLE_NAME": {
            "isSecret": true,
            "value": "",
            "enabled": true,
            "contentType": "",
            "expires": null
        }
    }
}

ServiceEndpoint Id is the AzureRm Service endpoint id which can be created using az devops service-endpoint command.

This worked for me, however it doesn't allow you to associate a service connection with the the variable group to access they key vault. Looks like there hasn't been an update to the cli yet, does anyone know if this is possible?

CharlieStokes avatar Jan 26 '21 11:01 CharlieStokes

Any updates on this feature?

yradsmikham avatar Feb 09 '21 22:02 yradsmikham

@geverghe > For clarification - there are no documented APIs to support this and we are working with the stakeholder to get an estimate on timeline. Will keep this thread posted.

Any updates?

lpalerm avatar Mar 01 '21 20:03 lpalerm

Any update on this feature?

balazzii avatar Oct 22 '21 09:10 balazzii

+1

brian-duffy avatar Feb 14 '22 19:02 brian-duffy

please give us this. would be incredibly useful for CRM solution/portal deployment

cT-m00cat avatar Mar 08 '22 12:03 cT-m00cat

plus one

cT-m00cat avatar Mar 08 '22 14:03 cT-m00cat

+1

daguadofnttdata avatar Mar 11 '22 11:03 daguadofnttdata

+1 Do you have any information about a future implementation?

frnode avatar May 31 '22 23:05 frnode

bump +4

cT-m00cat avatar Jun 01 '22 10:06 cT-m00cat

+1

DanielGoehler avatar Nov 03 '22 14:11 DanielGoehler

+1

rafaelvelosoAZ avatar Dec 12 '22 18:12 rafaelvelosoAZ

We definitely need this, as it's just about the last thing we can't automate for our pipeline creation. To have secrets in the keyvault, we have to manually go in and link the variable group to the keyvaults.

mddavisjha avatar Dec 16 '22 20:12 mddavisjha

+1 Thank you!

sderrico-descartes avatar Mar 28 '23 19:03 sderrico-descartes

And what about updating already existing VG that linked with KeyVault, adding existing secrets to variable group in particular? While this article says that PUT method should be used, modification to your command returns the following:

cli.azure.cli.core.azclierror: The requested resource does not support http method 'PUT'.
az_command_data_logger: The requested resource does not support http method 'PUT'.

Full CLI command:

az devops invoke --http-method put --area distributedtask --resource variablegroups --debug --in-file ./body3.json --encoding ascii --route-parameters project=redacted --api-version 7.1-preview
#body3.json
{
    "name": "redacted",
    "providerData": {
        "serviceEndpointId": "redacted",
        "vault": "redacted"
    },
    "type": "AzureKeyVault",
    "variableGroupProjectReferences": [
        {
            "projectReference": {
                "id": "redacted",
                "name": "redacted"
            },
            "name": "redacted",
            "description": ""
        }
    ],
    "variables": {
        "redacted": {
            "isSecret": true,
            "value": "",
            "enabled": true,
            "contentType": "",
            "expires": null
        }
    }
}

Invoking POST method to existing keyvault linked variable group results in:

cli.azure.cli.core.azclierror: Variable group 'vgsecretlookup-secret2' already exists.
az_command_data_logger: Variable group 'vgsecretlookup-secret2' already exists.

Please advice :)

pavel-rudenko avatar Feb 27 '24 13:02 pavel-rudenko

I do this with POST, exactly as the suggested az devops invoke comment states, and I add

    "authorized": true,
    "variableGroupProjectReferences": [
            {
                "projectReference": {
                    "id": "redacted",
                    "name": "redacted"
                },
                "name": "redacted",
                "description": ""
            }
        ],

luismesa-io avatar Apr 01 '24 11:04 luismesa-io

I do this with POST, exactly as the suggested az devops invoke comment states, and I add

    "authorized": true,
    "variableGroupProjectReferences": [
            {
                "projectReference": {
                    "id": "redacted",
                    "name": "redacted"
                },
                "name": "redacted",
                "description": ""
            }
        ],

And you are then able to create/update/link variable groups to keyvault without manual intervention?

StylezDevops avatar Apr 02 '24 09:04 StylezDevops