Is there a way to store YAML file in Azure Key Vault programatically?

Viewed 122

We are using a groovy script to store secrets and configs as YAML files in the SCM repo. Now, we are planning to move the secrets from SCM to the Azure Key Vault(AKV). So, I would like to know whether storing the YAML files in the AKV is possible or not?

Here is the structure of one of the YAML files,

- xxx:
    name: xxxx
    data1: xxxx
    data2: xxxx
- yyy:
    name: xxxx
    data1: xxxx
    data2: xxxx
- zzz:
    name: xxxx
    data1: xxxx
    data2: xxxx
1 Answers

I think you have multiple options.

1. Store as file

There must be a size limit, but you can easily store any text files in Key Vault and even provide the content type as there is a contentType field in the request/response of these REST endpoints:

2. Store as individual properties

If you want to avoid storing the whole YAML in one secret, you can flatten it and store the properties in their individual secrets but this approach has some secret name limitations (not all characters are allowed in names and length is limited) and it can cost more due to the larger number of requests.

Your example could be flattened into 9 secrets as:

xxx-name=xxxx
xxx-data1=xxxx
xxx-data2=xxxx
yyy-name=xxxx
yyy-data1=xxxx
yyy-data2=xxxx
zzz-name=xxxx
zzz-data1=xxxx
zzz-data2=xxxx
Related