App Service Configuration values not available in ssh session

Jonny Blain 0 Reputation points

When I ssh into the app service container, not all app settings are available. We are running a django app with a postgres database, and want to use the command line tools in django to make changes to the database, however this requires the configuration values to be available.

Is there anything specific that is needed to do to get this to work? Some variables do work, e.g. we have FIBRE_NAME that works, but POSTGRES_NAME doesn't.

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,186 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 17,136 Reputation points

    Hi @Jonny Blain thanks for the update on this issue and sharing what worked for you. Based on this GitHub thread it seems like this is a known issue Please see this GitHub repo: Quoting issues with PowerShell for more context.

    But to answer your question, if you have a password with special characters in it, you need to make sure that the characters are properly escaped when they are passed to the app and when they are loaded in the SSH shell so you can use stop-parsing symbol --% between az and arguments.

    The stop-parsing symbol (--%), introduced in PowerShell 3.0, directs PowerShell to refrain from interpreting input as PowerShell commands or expressions. When it encounters a stop-parsing symbol, PowerShell treats the remaining characters in the line as a literal.

    For instance,

    az --% vm create --name xxx

    But keep in mind that the command still needs to be escaped following the Command Prompt syntax.

    # Use --% to stop PowerShell from parsing the argument and escape double quotes
    # following the Command Prompt syntax
    > python.exe --% -c "import sys; print(sys.argv[1])" "\"some quoted text\""
    "some quoted text"

    Also to avoid unanticipated results, here are a few suggestions found in this document- Tips for using the Azure CLI successfully:**

    • If you provide a parameter that contains whitespace, wrap it in quotation marks.

    In Bash or PowerShell, both single and double quotes are interpreted correctly. In Windows Command Prompt, only double quotes are interpreted correctly -- single quotes are treated as part of the value.

    If your command is only going to run on Bash (or Zsh), use single quotes to preserve the content inside the JSON string. This is necessary when supplying inline JSON values. For example, this JSON is correct in Bash: '{"key": "value"}'.

    If your command will be run at a Windows Command Prompt, you must use double quotes. If the value contains double quotes, you must escape it. The equivalent of the above JSON string is "{\"key\": \"value\"}"

    In Powershell, if your value is an empty string, please use '""'.

    In Bash or Powershell, if your value is an empty quotes string '', please use "''".

    • Use Azure CLI's @<file> convention to load from a file and bypass the shell's interpretation mechanisms.
    az ad app create --display-name myName --native-app --required-resource-accesses @manifest.json

    Bash evaluates double quotes in exported variables. If this behavior isn't what you want, escape the variable: "\$variable".

    Some Azure CLI commands take a list of space separated values.

    • If the key name or value contains spaces, wrap the whole pair: "my key=my value". For example:
    az web app config app settings set --resource-group myResourceGroup --name myWebAppName --settings "client id=id1" "my name=john"

    When a CLI parameter states that it accepts a space-separated list, one of two formats is expected:

    1. Unquoted, space-separated list --parameterName firstValue secondValue
    2. Quoted space-separated list --parameterName "firstValue" "secondValue"

    This example is a string with a space in it. It is not a space-separated list: --parameterName "firstValue secondValue"

    • There are special characters of PowerShell, such as at @. To run Azure CLI in PowerShell, add ` before the special character to escape it. You can also enclose the value in single or double quotes "/".
    # The following three examples will work in PowerShell
    --parameterName `@parameters.json
    --parameterName '@parameters.json'
    --parameterName "@parameters.json"
    # This example will not work in PowerShell
    --parameterName @parameters.json

    Hope that helps.



    0 comments No comments