![](/img/trans.png)
[英]I am trying to deploy a Logic-App with a Service-Bus Deploy to azure app using Bicep template
[英]How to deploy windows Azure App Service with .Net stack using Bicep?
我创建了一个 Bicep 来部署服务计划和应用程序服务,选择 linux/windows 和 .net 6 堆栈。 两次部署均成功,Linux 应用程序完全正常,.net 门户网站上存在 6 个堆栈。 然而, Windows 堆栈在 Portal 屏幕上是空的。
我正在使用以下参数:
二头肌linux参数:
linuxFxVersion: 'DOTNETCORE|6.0'
二头肌Windows参数:
windowsFxVersion: 'dotnet:6'
netFrameworkVersion: 'v6.0'
使用此命令,我可以使用 windows 个堆栈,所以 do.net:6 应该没问题
[ ~ ]$ az webapp list-runtimes --os windows --os-type windows
[
"dotnet:7",
"dotnet:6",
"ASPNET:V4.8",
"ASPNET:V3.5",
"NODE:18LTS",
...
我可以看到 Powershell,我的设置应用于Web App 。
我尝试了不同的选项,如 do.net|6、do.netcore|6 或 without.netFrameworkVersion,但没有找到合适的选项。 是 Azure 接口错误还是我遗漏了什么? 提前致谢,附上下面的整个二头肌。
@description('Generate unique String for resource names')
param uniqueFullRGString string = uniqueString(resourceGroup().id)
@description('Short unique name based on RG name')
param uniqueRGString string = take(uniqueFullRGString, 4)
@description('Resource group location')
param location string = resourceGroup().location
@description('Azure Tenant Id')
var azureTenantId = tenant().tenantId
@description('App Service Plan OS')
@allowed([
'linux'
'windows'
])
param appServicePlanOS string
var linuxOffer = 'linux'
var windowsOffer = 'windows'
@description('App Service Plan SKU')
param appServicePlanSku string = 'F0'
var configReferenceLinux = {
linuxFxVersion: 'DOTNETCORE|6.0'
appSettings: [
{
name: 'TenantId'
value: azureTenantId
}
]
}
var configReferenceWindows = {
windowsFxVersion: 'dotnet:6'
netFrameworkVersion: 'v6.0'
appSettings: [
{
name: 'TenantId'
value: azureTenantId
}
]
}
@description('App Service Plan name')
var appServicePlanName = 'App-${uniqueRGString}'
resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: appServicePlanName
location: location
sku: {
name: appServicePlanSku
}
properties: {
reserved: ((appServicePlanOS == 'linux') ? true : false)
}
kind: ((appServicePlanOS == 'linux') ? linuxOffer : windowsOffer)
}
resource appService 'Microsoft.Web/sites@2020-06-01' = {
name: appServicePlanName
location: location
properties: {
serverFarmId: appServicePlan.id
siteConfig: ((appServicePlanOS == 'linux') ? configReferenceLinux : configReferenceWindows)
}
identity: {
type: 'SystemAssigned'
}
}
我在我的环境中运行了您的代码并得到了相同的结果(空运行时堆栈)。 然后我将提供商“Microsoft.Web/sites”版本更改为“2021-03-01”并且它成功运行,因为很少有部署版本会抛出此类错误。
我对您的代码进行了一些更改,并找到了以下代码段。
resource appService 'Microsoft.Web/sites@2021-03-01' = {
name: appServicePlanName
location: "EastUS" //location
properties: {
serverFarmId: appServicePlan.id
siteConfig: ((appServicePlanOS == 'windows') ? configReferenceLinux : configReferenceWindows)
}
identity: {
type: 'SystemAssigned'
}
}
部署成功:
App service -> configuration -> General settings -> Stack settings
设置为给定的运行时堆栈和版本:
如果您尝试在 windows 应用程序服务计划上部署 .NET 堆栈 webapp,那么您需要添加元数据块,该元数据块用于定义您的 webapp 的运行时间,如本示例 ARM 模板中所述,以在 windows 应用程序服务计划上创建 .NET 应用程序。
我修改了上面的共享示例 bicep 并测试了它能够部署 windows 应用程序服务计划,webapp 运行在 .NET 堆栈上。
@description('Generate unique String for resource names')
param uniqueFullRGString string = uniqueString(resourceGroup().id)
@description('Short unique name based on RG name')
param uniqueRGString string = take(uniqueFullRGString, 4)
@description('Resource group location')
param location string = resourceGroup().location
@description('Azure Tenant Id')
var azureTenantId = tenant().tenantId
@description('App Service Plan OS')
@allowed([
'linux'
'windows'
])
param appServicePlanOS string
var linuxOffer = 'linux'
var windowsOffer = 'windows'
@description('App Service Plan SKU')
param appServicePlanSku string = 'F0'
var configReferenceLinux = {
linuxFxVersion: 'DOTNETCORE|6.0'
appSettings: [
{
name: 'TenantId'
value: azureTenantId
}
]
}
var configReferenceWindows = {
metadata :[
{
name:'CURRENT_STACK'
value:'dotnet'
}
]
netFrameworkVersion:'v7.0'
appSettings: [
{
name: 'TenantId'
value: azureTenantId
}
]
}
@description('App Service Plan name')
var appServicePlanName = 'App-${uniqueRGString}'
resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
name: appServicePlanName
location: location
sku: {
name: appServicePlanSku
}
properties: {
reserved: ((appServicePlanOS == 'linux') ? true : false)
}
kind: ((appServicePlanOS == 'linux') ? linuxOffer : windowsOffer)
}
resource appService 'Microsoft.Web/sites@2020-06-01' = {
name: appServicePlanName
location: location
properties: {
serverFarmId: appServicePlan.id
siteConfig: ((appServicePlanOS == 'linux') ? configReferenceLinux : configReferenceWindows)
}
identity: {
type: 'SystemAssigned'
}
}
样例Output 截图供参考:
您也可以参考这个类似的SO 线程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.