An Azure service that provides an event-driven serverless compute platform.
Hello Stepan Hlushak,
Welcome to the Microsoft Q&A and thank you for posting your questions here.
I understand that you are having errors in az cli when trying to set/get ContainerApp function keys.
First, ensure the Container App is actively running by forcing at least one replica using
az containerapp update --name <app> --resource-group <rg> --set template.scale.minReplicas=1
Then confirm an active revision exists with az containerapp revision list -o table, as required in Microsoft Docs: https://learn.microsoft.com/azure/container-apps/scale-app.
Next, verify the Function host inside the container is fully initialized, since CLI operations depend on it.
az containerapp logs show --name <app> --resource-group <rg>
Check for “Host started” in logs, aligning with diagnostics guidance: https://learn.microsoft.com/azure/container-apps/logging.
After that, retrieve the active revision name because multi-revision apps require explicit targeting.
REVISION=$(az containerapp revision list --name <app> --resource-group <rg> --query "[?properties.active].name" -o tsv)
This ensures the CLI interacts with the correct running revision per revision management docs.
Then execute the CLI command only after validation steps are satisfied.
az containerapp function keys list --name <app> --resource-group <rg> --revision $REVISION --key-type hostKeys
If prerequisites are unmet, the command fails due to runtime dependency as documented in Azure CLI references.
Finally, if the CLI still fails, switch to the REST API which bypasses runtime execution entirely.
az rest --method POST --url "https://management.azure.com/subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.App/containerApps/<app>/functions/admin/host/keys?api-version=2024-03-01"
This direct management-plane call is the most reliable method per Azure REST API guidance: https://learn.microsoft.com/rest/api/resource-manager/.
I hope this is helpful! Do not hesitate to let me know if you have any other questions or clarifications.
Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful.