1

I'm attempting to create an Azure Container app using the CLI (az containerapp create), but the command is not recognizing the arguments (--args) provided.

Reference for the command: https://learn.microsoft.com/en-us/cli/azure/containerapp?view=azure-cli-latest#az-containerapp-create

Error attempt 1:

az containerapp create \
::
::
  --command "celery" \
  --args "-A", "gagenerator.celery.celery", "worker", "--loglevel=INFO", "-P", "threads"
unrecognized arguments: -A, gagenerator.celery.celery, worker, --loglevel=INFO, -P, threads

Error attempt 2:

az containerapp create \
::
::
  --command "celery" \
  --args "-A" "gagenerator.celery.celery" "worker" "--loglevel=INFO" "-P" "threads"
unrecognized arguments: -A gagenerator.celery.celery worker --loglevel=INFO -P threads

I'm able to create the app using UI:

enter image description here

1
  • The --args parameter in az containerapp create should be passed as a single space-separated string or multiple arguments enclosed in square brackets ([]). So use:--args '["-A", "gagenerator.celery.celery", "worker", "--loglevel=INFO", "-P", "threads"]' Commented Mar 21 at 4:12

1 Answer 1

2

The error you're facing is because,

  • In attempt 1, you used comma-separated values for --args, which the Azure CLI does not support.
  • In attempt 2 arguments are provided separately without being enclosed in a string or a JSON array.

az containerapp create command expects either a single space-separated string containing all arguments or a JSON-style arraywith each argument as a separate string.

So, replace your current command with,

  1. Space-separated string format:
az containerapp create \
  --name <container-app> \
  --resource-group <resource-group> \
  --image <container-image> \
  --command "celery" \
  --args "-A gagenerator.celery.celery worker --loglevel=INFO -P threads"
  1. JSON array format:
az containerapp create \
  --name <container-app> \
  --resource-group <resource-group> \
  --image <container-image> \
  --command "celery" \
  --args '["-A", "gagenerator.celery.celery", "worker", "--loglevel=INFO", "-P", "threads"]'

Please refer this Msdoc for better understanding of commands format.

Sign up to request clarification or add additional context in comments.

7 Comments

Space-separated string format: command recognized but deployment failed with "Error: Invalid value for '-A' / '--app': ModuleNotFoundError: No module named ' gagenerator'". UI shows this as arguments which is different from the UI screenshot I shared on my question: -A gagenerator.celery.celery worker --loglevel=INFO -P threads
JSON array format: command recognized but deployment failed with "Error: No such command '["-A", "gagenerator.celery.celery", "worker", "--loglevel=INFO", "-P", "threads"]'". UI shows this as arguments which is different from the UI screenshot I shared on my question: ["-A", "gagenerator.celery.celery", "worker", "--loglevel=INFO", "-P", "threads"]
Tried this as well: --args '[-A, gagenerator.celery.celery, worker, --loglevel=INFO, -P, threads]' Error: No such command '[-A, gagenerator.celery.celery, worker, --loglevel=INFO, -P, threads]'.
Tried this which results in the same UI screenshot I shared on my question: --args '-A, gagenerator.celery.celery, worker, --loglevel=INFO, -P, threads' But deployment fails with Error: "ModuleNotFoundError: No module named ', gagenerator'" Don't know why the deployment is failing in that case. If I just update it through UI, for example by changing any config to force update the container, then it works fine.
@Thiago Scodeler can you please remove the spaces and try this --args '["-A","gagenerator.celery.celery","worker","--loglevel=INFO","-P","threads"]'
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.