AppConfiguration
AppConfiguration copied to clipboard
Allow querying for multiple labels from ARM Template using listKeyValue
I have been exploring the integration of App Configuration with ARM templates. Ideally I would like to be able to query for the value of key with an array of labels, returning only the first matching value.
Example scenario: An overly simple example might be the following.
{
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.9",
"parameters": {
"environment": {
"type": "String",
"defaultValue": "dev",
"metadata": {
"description": "This is the SDLC environment that is being deployed to."
}
}
},
"variables": {
"keyVaultName":"[concat(parameters('environment'),'-keyvault01')]",
"skuFamily": {
"key": "/keyvault/sku/family",
"label": ["[variables('keyVaultName')]","[parameters('environment')]", "default"]
},
"skuName": {
"key": "/keyvault/sku/name",
"label": ["[variables('keyVaultName')]","[parameters('environment')]", "default"]
},
"enableSoftDelete": {
"key": "/keyvault/enableSoftDelete",
"label": ["[variables('keyVaultName')]","[parameters('environment')]", "default"]
}
},
"resources": [
{
"type": "Microsoft.KeyVault/vaults",
"apiVersion": "2016-10-01",
"name": "[variables('keyVaultName')]",
"location": "northcentral",
"properties": {
"sku": {
"family": "[listKeyValue(resourceId('Microsoft.AppConfiguration/configurationStores', 'appConfig01'), '2019-10-01',variables('skuFamily')).value]",
"name": "[listKeyValue(resourceId('Microsoft.AppConfiguration/configurationStores', 'appConfig01'), '2019-10-01',variables('skuName')).value]"
},
"accessPolicies": [],
"tenantId": "53a61a04-8224-4d62-b270-a5823ebeb33c",
"enabledForDeployment": false,
"enabledForDiskEncryption": false,
"enabledForTemplateDeployment": false,
"enableSoftDelete": "[listKeyValue(resourceId('Microsoft.AppConfiguration/configurationStores', 'appConfig01'), '2019-10-01',variables('enableSoftDelete')).value]"
}
}
]
}
You can see that I am querying for some configuration Keys for Sku and enableSoftDelete. I am ordering my array of labels from most specific to least in this case. Enabling something like this would allow me to:
- Provide a default for everything (least specific).
- All keyvaults will be deployed as standard
- Allow for an overload based on environment (more specific).
- All keyvaults in production will be deployed as premium
- While also allowing me to handle an exception for a specific named instance (most specific).
- This specific production keyvault should be standard.
@jasonbrisbin sorry for the late response. We are moving away from the listKeyValue
API. Instead, we introduced KeyValues
as a child resource in the new version 2020-07-01-preview
, so you can query key-values by the standard ARM reference. Please check out the documentation for more details.
https://docs.microsoft.com/en-us/azure/azure-app-configuration/quickstart-resource-manager
@jasonbrisbin please let us know if you have further questions. Closing for now.
I don't see where KeyValues would allow for querying a single key with multiple labels as I mentioned initially. Is that possible?
@jasonbrisbin you will have to query (reference) each key+label individually.
If a key and label is not found will it throw an error?
I suppose referencing a key-value that does not exist will cause errors when running the template. @ZhijunZhao can you please confirm?
@jasonbrisbin Yes, it would throw error like below.
C:\>az deployment group create -g test-resource-group --template-file app-config-kv-template.json
Deployment failed. Correlation ID: f4b71fb2-1ff2-4af3-9bd4-d5dd52bf4129. {
"code": "EntityNotFound",
"message": "The resource with id 'myKey$myLabel' was not found."
}
The core problem then remains.
@jasonbrisbin ARM template does not support querying of multiple labels at once. But, @ZhijunZhao, is there a way to achieve what @jasonbrisbin wanted: query for the value of key with an array of labels, returning only the first matching value using what we have today?
@zhenlan I think what @jasonbrisbin has is a sound case. But we have to add an API to support this. We could improve the listKeyValue
API with key-label array input. More discussion is needed.
Can we reopen this? I don't know why it was closed and would very much like this capability.
@jasonbrisbin sure, reopened. The listKeyValue
API will not be continued in the new version. However, we need to figure out how to support the scenario via the 'KeyValue' resource.
cc: @jimmyca15 @MSGaryWang
Any updates on this enhancement?