jge*_*lin 7 azure azure-web-app-service
我正在尝试在 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
}
Run Code Online (Sandbox Code Playgroud)
我尝试了各种不同的属性和环境,但没有成功。我总是收到这个错误。这是我正在使用的 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
);
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
小智 13
原因:
您的应用服务计划不是 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')]"
}
}
Run Code Online (Sandbox Code Playgroud)
我测试了你的 json 数据,它导致你的properties. 您的 json 数据没有“properties”属性。如果您想使用 json 属性创建 Web,请检查此 Web 应用程序 Rest API 请求 body\xef\xbc\x9a Web Apps - Create Or Update。
正确的格式应类似于以下示例:
\n\n {\n "location": "CentralUS",\n "kind":"app,linux",\n "properties":{\n "serverFarmId":"your Resource ID",\n "siteConfig":{\n "linuxFxVersion":"JAVA|11-java11"\n }\n }\n\n }\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
4464 次 |
| 最近记录: |