Azure / azure-cli

Azure Command-Line Interface
MIT License
4.03k stars 3k forks source link

AppConfig Key Vault reference import causes invalid Content Type for YAML files #14845

Open ChristopherL-STCU opened 4 years ago

ChristopherL-STCU commented 4 years ago

Describe the bug

I see in the release notes there was recently the breaking change "Support settings with JSON content type" for AppConfig and I suspect this is what is impacting me.

Command Name az appconfig kv import

Errors:

Failed to import 'yaml' file format with 'application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8' content type. Please provide JSON file format to match your content type.

To Reproduce:

Steps to reproduce the behavior.

Expected Behavior

Previously this would import the new property, now the above error occurs. If I change the content type by excluding +json or changing it to something else then the property is created but it is not a Key Vault reference. Is it possible to import a new Key Vault reference property within a YAML file in version 2.10.1 of the CLI?

Environment Summary

Linux-4.15.0-1092-azure-x86_64-with-debian-10.2 (Cloud Shell)
Python 3.6.10
Installer: DEB

azure-cli 2.10.1

Additional Context

ghost commented 4 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @shenmuxiaosen, @avanigupta.

yonzhan commented 4 years ago

appconfig

avanigupta commented 4 years ago

Hi @ChristopherL-STCU, thanks for providing all the details. You're right, importing KeyVault references from a YAML file will not be possible with Azure CLI version 2.10.0 or later. This change was recently introduced in order to support proper import/export of key-values in App Configuration without losing their data type. So if you want to import settings with valid JSON values and a valid JSON content-type, you need to provide the settings in a JSON file. We currently do not support importing key-values from a YAML file with JSON content-type. For more information, see this how-to guide.

However, you can still import your KeyVault references from a JSON file. Key Vault references are already in JSON format and the reserved content-type for KeyVault references is also a valid JSON content-type. Your test file in JSON format should look like this:

{
   "MySecret": {
      "uri": "https://my-key-vault.vault.azure.net/secrets/my-secret"
   }
}

And this would be the CLI command for importing KeyVault references:

az appconfig kv import -s file --path test.json --format json -n STCU-App-Config --content-type "application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8"

Let me know if that helps!

ChristopherL-STCU commented 4 years ago

Thank you @avanigupta. I will move our App Configuration files from YAML to JSON.

navba-MSFT commented 2 years ago

@ChristopherL-STCU Apologies for the late reply. I hope your issue is addressed. This github thread is open for quite sometime. Could you please let us know if you need any further assistance on this ? Awaiting your reply.

ChristopherL-STCU commented 2 years ago

Thanks @navba-MSFT. From @avanigupta comment my understanding is that YAML import was deprecated. So the issue remains but my understanding is it is expected and that there are no plans to support YAML functionality. If this is correct then it seems this issue can be closed. But if YAML deprecation was a mistake and this functionality is intended then this issue can remain open to track it.

avanigupta commented 2 years ago

Hi @ChristopherL-STCU, this issue occurred because we don't support importing key-values from a YAML file with JSON content-type. If you still want this feature, feel free to open a new issue in https://github.com/Azure/AppConfiguration/issues repo and we will get this prioritized.

@navba-MSFT, this issue can be closed now.

carlin-q-scott commented 9 months ago

When I exported from az app config using the UI, it produced this key vault reference:

MySecret:
  uri: 'https://my-vault.vault.azure.net/secrets/MySecret'

This looks like an exact conversion from @avanigupta's example of the reference using the json file format. I'll bet this works fine for importing.

Update

While secret refs do export that way, they do not import correctly.