azure-web-app-service - 在二头肌模板上设置 Azure 应用服务服务器堆栈
问题描述
我正在尝试使用 Azure CLI 中的 Bicep 模板在 Linux 上部署 .NET Core 3.1 Azure App Service。应用服务和相应的应用服务计划已正确部署,但 Azure 门户上的应用服务堆栈设置为空,我必须手动设置这些设置。我尝试在“Microsoft.Web/sites”资源和“Microsoft.Web/sites/config”资源上设置元数据属性,但结果是一样的。
这是我的应用服务计划:
resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
name: 'MyAppService'
location: resourceGroup().location
properties: {
reserved: true
}
sku: {
name: 'P1v2'
}
kind: 'linux'
}
这是我第一次尝试使用此处建议的“Microsoft.Web/sites”设置堆栈:
https://github.com/Azure/bicep/issues/3314
resource appService 'Microsoft.Web/sites@2021-02-01' = {
name: 'MyApp'
location: resourceGroup().location
identity: {
type: 'SystemAssigned'
}
kind: 'app'
properties: {
enabled: true
serverFarmId: appServicePlan.id
siteConfig: {
linuxFxVersion: 'dotnet|3.1'
appCommandLine: 'dotnet MyApp.dll'
metadata: [
{
name: 'CURRENT_STACK'
value: 'dotnetcore'
}
]
}
}
}
这是我第二次尝试使用此处建议的“Microsoft.Web/sites/config”设置堆栈:
Bicep - 如何将运行时堆栈配置到 Azure 应用服务(Bicep 版本 0.4)
resource appService 'Microsoft.Web/sites@2021-02-01' = {
name: 'MyApp'
location: resourceGroup().location
identity: {
type: 'SystemAssigned'
}
kind: 'app'
properties: {
enabled: true
serverFarmId: appServicePlan.id
siteConfig: {
linuxFxVersion: 'dotnet|3.1'
appCommandLine: 'dotnet MyApp.dll'
}
}
resource webConfig 'config' = {
name: 'web'
properties: {
metadata: [
{
name: 'CURRENT_STACK'
value: 'dotnetcore'
}
]
}
}
}
结果是一样的。部署完成并出现以下警告:
警告 BCP037:“SiteConfig”类型的对象不允许使用“元数据”属性。允许的属性包括“acrUseManagedIdentityCreds”、“acrUserManagedIdentityID”、“alwaysOn”、“apiDefinition”、“apiManagementConfig”、“autoHealEnabled”、“autoHealRules”、“autoSwapSlotName”、“azureStorageAccounts”、“connectionStrings”、“cors”、“defaultDocuments” 、“detailedErrorLoggingEnabled”、“documentRoot”、“experiments”、“ftpsState”、“functionAppScaleLimit”、“functionsRuntimeScaleMonitoringEnabled”、“handlerMappings”、“healthCheckPath”、“http20Enabled”、“httpLoggingEnabled”、“ipSecurityRestrictions”、“
资源已部署,但应用服务堆栈设置为空白,我必须手动设置才能使其正常工作。
我知道在 ARM 模板中,这是在 Microsoft.Web/sites/config 元数据的 CURRENT_STACK 属性上设置的(如此处建议的https://cloudstep.io/2020/11/18/undocumented-arm-oddities-net-核心应用服务/)。但是,二头肌似乎(尚)不支持此功能。如果有人找到了可行的解决方案,请在此处发布。谢谢。
解决方案
Metadata 参数在SiteConfig
. 可以提到堆栈设置LinuxFxVersion
。
因此,解决方案将不是使用dotnet|3.1
,而是应该使用DOTNETCORE|3.1
。所有代码如下:
resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
name: 'MyAppService'
location: resourceGroup().location
properties: {
reserved: true
}
sku: {
name: 'P1v2'
}
kind: 'linux'
}
resource appService 'Microsoft.Web/sites@2021-02-01' = {
name: 'anumantestapp'
location: resourceGroup().location
identity: {
type: 'SystemAssigned'
}
kind: 'app'
properties: {
enabled: true
serverFarmId: appServicePlan.id
siteConfig: {
linuxFxVersion: 'DOTNETCORE|3.1'
appCommandLine: 'dotnet MyApp.dll'
}
}
}
输出:
推荐阅读
- javascript - 使用 webpack 时 IE11 中箭头函数的语法错误
- json - 将数据从 json 解析为 MutableLiveData 时可以转换数据吗
- scala - 生成具有 int 字段且不重复的案例类列表
- r - 如何通过采样包含在R中重复n次的字符来创建向量“a”?
- python - 如何优化大型列表的功能合并排序
- android - 如何在 IntelliJ IDEA for Flutter 中编辑 Android 代码
- javascript - 有没有办法在javascript中重新组织以下数组?
- php - 无法在其他文件中使用 $_SESSION (PHP)
- c# - Windows server 2012 上的 MSMQ 远程专用队列
- python - 在张量流 keras 中动态组合损失函数