Azure / azure-cli

Azure Command-Line Interface
MIT License
3.92k stars 2.88k forks source link

"az appconfig kv export --destination appservice" produces "Failed to read key-values from appservice" when DOCKER_REGISTRY_SERVER_PASSWORD exists in app service #29270

Open bruschke opened 1 week ago

bruschke commented 1 week ago

Describe the bug

Found that I continued to receive "Failed to read key-values from appservice. 'NoneType' object has no attribute 'strip'" when trying to export my configuration values from App Configuration Service to my App Service. I was able to finally get around the issue by removing the DOCKER_REGISTRY_SERVER_PASSWORD environment variable from app service. My work around is to delete the variable, then run the export command, and then re-insert the variable (in my case I stored the value in a separate key vault in order to re-create it.)

Related command

This is my command with my workaround logic:

DELETE ENV VAR DOCKER_REGISTRY_SERVER_PASSWORD

az webapp config appsettings delete --name my-app-service --resource-group my-resource-group --setting-names DOCKER_REGISTRY_SERVER_PASSWORD --only-show-errors

EXPORT CONFIG TO APP SERVICE

az appconfig kv export \ --auth-mode login \ --endpoint https://my-config.azconfig.io \ --destination appservice \ --appservice-account /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/my-resource-group/providers/Microsoft.Web/sites/my-app-service \ --label my-label \ --export-as-reference true \ --skip-features true \ --only-show-errors \ --yes

PULL DOCKER_REGISTRY_SERVER_PASSWORD VALUE FROM KEY VAULT

docker_password=$(az keyvault secret show --vault-name my-vault --name docker-registry-server-password --query value -o tsv)

RE-CREATE ENV VAR DOCKER_REGISTRY_SERVER_PASSWORD

az webapp config appsettings set --name my-app-service --resource-group my-resource-group --settings DOCKER_REGISTRY_SERVER_PASSWORD=$docker_password

Errors

Failed to read key-values from appservice. 'NoneType' object has no attribute 'strip'

Issue script & Debug output

N/A - See error message

Expected behavior

az appconfig kv export --destination appservice can be run successfully even when the DOCKER_REGISTRY_SERVER_PASSWORD environment variable is present

Environment Summary

azure-cli 2.61.0

core 2.61.0 telemetry 1.1.0

Extensions: azure-devops 1.0.1

Dependencies: msal 1.28.0 azure-mgmt-resource 23.1.1

Python location '/opt/az/bin/python3' Extensions directory '/opt/az/azcliextensions'

Python (Linux) 3.11.8 (main, May 16 2024, 03:47:28) [GCC 11.4.0]

Legal docs and information: aka.ms/AzureCliLegal

Your CLI is up-to-date.

Additional context

No response

yonzhan commented 1 week ago

Thank you for opening this issue, we will look into it.

microsoft-github-policy-service[bot] commented 1 week ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @RandalliLama, @schaabs, @jlichwa.

microsoft-github-policy-service[bot] commented 1 week ago

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