azure - 从 Node.js 创建 WebApp 资源时,“参数 LinuxFxVersion 的值无效”
问题描述
我正在尝试在 Node.js 环境中使用 Azure SDK for JS 创建一个简单的 WebApp,但我不断收到响应:
{
"Code":"BadRequest",
"Message":"The parameter LinuxFxVersion has an invalid value.",
"Target":null,
"Details":[
{"Message":"The parameter LinuxFxVersion has an invalid value."},
{"Code":"BadRequest"},
{"ErrorEntity": {
"ExtendedCode":"01007",
"MessageTemplate":"The parameter {0} has an invalid value.",
"Parameters":["LinuxFxVersion"],
"Code":"BadRequest",
"Message":"The parameter LinuxFxVersion has an invalid value."}
}],
"Innererror":null
}
我尝试了各种不同的属性和环境集,但都没有成功。我总是收到这个错误。这是我正在使用的 TypeScript 代码片段:
const wsmClient: WebSiteManagementClient...
const webAppName: string...
const servicePlanId: string...
const rgName: string...
const envelope: Site = {
name: webAppName,
location: 'westus2',
kind: 'app,linux',
serverFarmId: servicePlanId,
siteConfig: {
linuxFxVersion: 'JAVA|11-java11'
}
};
const appResp = await wsmClient.webApps.createOrUpdate(
rgName,
webAppName,
envelope
);
我究竟做错了什么?
解决方案
原因:
您的应用服务计划不是 Linux,实际上是 Windows。Windows 主机没有参数 LinuxFxVersion。
如果我们创建站点时没有将主机显式配置为 Linux,则默认情况下它将是 Windows 主机/serverFarm/app 服务计划。使用 {"kind":"linux"} 是不够的。
解决方案:
在 Linux 中明确定义应用服务计划,并确保{"reserved": true}
将其设置为 Linux 主机(参见文档)
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2019-08-01",
"name": "[parameters('hostingPlanName')]",
"location": "[parameters('location')]",
"kind": "app,linux",
"properties": {
"reserved": true
},
"sku": {
"Tier": "[parameters('hostingPlanSkuTier')]",
"Name": "[parameters('hostingPlanSkuName')]"
}
}
推荐阅读
- api - 不明白为什么我的 Haskell API 调用脚本返回“Nothing”
- windows - 无法在 Windows cmd 上运行来自本地 npm 包(webpack、babel 等)的命令。不存在的 cygdrive/c 路径出现错误。不使用 cygwin
- php - 使用 PHPWord 库读取 word 文件时如何检测 EOF(文件结尾)字符
- python - 如何在 python 中从 pywikibot 获取重定向
- verilog - 在 Verilog 中增加一个变量以索引导线(使用循环)
- python-3.x - 如何关闭 PRAW Reddit 实例?
- reactjs - 出现在组件上方的 Material UI Select 按钮标签
- python - Python函数以挂起的程序结束
- java - Spring Batch如何使用具有其他对象列表的对象持久化到数据库中
- windows - 在 Enclave 中加载 DLL 失败并显示 ERROR_INVALID_IMAGE_HASH