首页 > 解决方案 > 如何在 Azure 函数应用中更改 LinuxFxVersion

问题描述

我有天蓝色的功能,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,我需要使用 Power shell 来更改它:

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?

标签: azurepowershellazure-functions

解决方案


在 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


推荐阅读