如何在 Azure 函数应用程序中更改 LinuxFxVersion

How to change LinuxFxVersion in Azure function app

我有 azure 函数 LinuxFxVersion 设置为 DOTNET:

"siteProperties": {
"metadata": null,
"properties": [
    {
        "name": "LinuxFxVersion",
        "value": "DOTNET|3.1"
    },
    {
        "name": "WindowsFxVersion",
        "value": null
    }
  ],
    "appSettings": null
},

我想设置为Python:

"siteProperties": {
"metadata": null,
"properties": [
    {
        "name": "LinuxFxVersion",
        "value": "Python|3.9"
    },
    {
        "name": "WindowsFxVersion",
        "value": null
    }
  ],
    "appSettings": null
},

根据msdn source,我需要使用Powershell来改变它:

az functionapp config set --name <func_name> --resource-group <rg> --linux-fx-version 'Python|3.9'

但我收到错误:

'3.9' is not recognized as an internal or external command,
operable program or batch file.

当我输入 'Python' 时,我收到回复:

Operation returned an invalid status 'Bad Request'

如何将 Azure Function 中的 linux fx 版本从 .NET 更改为 Python?

在 Powershell 中解决此错误的方法是用引号将包含竖线字符的字符串括起来。

这里有多个例子:

  • az functionapp config set --name <func_name> --resource-group <rg> --linux-fx-version '"Python|3.9"'
  • az functionapp config set --name <func_name> --resource-group <rg> --linux-fx-version 'Python"|"3.9'

如果你是 运行 bash 中的上述命令,请使用 : 而不是 |

  • az functionapp config set --name <func_name> --resource-group <rg> --linux-fx-version "Python:3.9"

https://octopus.com/blog/powershell-pipe-escaping

https://github.com/Azure/azure-cli/issues/7874