Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow querying for multiple labels from ARM Template using listKeyValue #412

Open
jasonbrisbin opened this issue Sep 28, 2020 · 14 comments
Open
Labels
ARM enhancement New feature or request

Comments

@jasonbrisbin
Copy link

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.
@zhenlan
Copy link
Contributor

zhenlan commented Oct 8, 2020

@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

@zhenlan zhenlan self-assigned this Oct 21, 2020
@zhenlan
Copy link
Contributor

zhenlan commented Oct 21, 2020

@jasonbrisbin please let us know if you have further questions. Closing for now.

@zhenlan zhenlan closed this as completed Oct 21, 2020
@jasonbrisbin
Copy link
Author

I don't see where KeyValues would allow for querying a single key with multiple labels as I mentioned initially. Is that possible?

@zhenlan
Copy link
Contributor

zhenlan commented Oct 21, 2020

@jasonbrisbin you will have to query (reference) each key+label individually.

@jasonbrisbin
Copy link
Author

If a key and label is not found will it throw an error?

@zhenlan
Copy link
Contributor

zhenlan commented Oct 22, 2020

I suppose referencing a key-value that does not exist will cause errors when running the template. @ZhijunZhao can you please confirm?

@ZhijunZhao
Copy link

@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."
}

@jasonbrisbin
Copy link
Author

The core problem then remains.

@zhenlan
Copy link
Contributor

zhenlan commented Dec 14, 2020

@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?

@ZhijunZhao
Copy link

@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.

@jasonbrisbin
Copy link
Author

Can we reopen this? I don't know why it was closed and would very much like this capability.

@zhenlan zhenlan reopened this Mar 19, 2021
@zhenlan
Copy link
Contributor

zhenlan commented Mar 19, 2021

@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.

@zhenlan
Copy link
Contributor

zhenlan commented Mar 19, 2021

cc: @jimmyca15 @MSGaryWang

@zhenlan zhenlan added enhancement New feature or request and removed question labels Mar 19, 2021
@jasonbrisbin
Copy link
Author

Any updates on this enhancement?

@zhenlan zhenlan removed their assignment Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ARM enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants