我正在尝试制作一个简单的 Bicep 模块,该模块将能够在 Linux 上部署 .NET 应用服务,但在尝试创建资源时遇到内部服务器错误。
创建如下所示的 dotnet_app_service.bicep 后:
targetScope = 'resourceGroup'
param location string = resourceGroup().location
param project string
param app_service_name string
param environment string
param instance int
param app_service_plan_id string
param dotnet_version string
param app_settings array
var name = toLower('app-${app_service_name}-${environment}-00${instance}')
resource app_service 'Microsoft.Web/sites@2024-04-01' = {
name: name
location: location
kind: 'app,linux'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: app_service_plan_id
siteConfig: {
netFrameworkVersion: 'v${dotnet_version}'
appSettings: app_settings
}
}
tags: {
DevOpsProject: project
IaC: 'true'
}
}
我尝试使用 Azure CLI 命令部署资源:
az deployment group create --resource-group <my_resource_group> --subscription <my_subscription_id> --parameters environment=test instance=1 linux_app_service_plan_name=<my_project_name> linux_app_service_plan_sku=F1 --template-file main.bicep
main.bicep 提供其余参数:
但是我在控制台上的 JSON 输出中收到以下错误:
There was an unexpected InternalServerError. Please try again later.
我无法从这里获得任何答案,因为内部服务器错误通常与另一端相关? 希望获得与该主题相关的一些帮助。 谢谢!
对于Linux应用程序服务,您需要指定
linuxFxVersion
属性:
linuxFxVersion: 'DOTNETCORE|${dotnet_version}'
完整样本:
param location string = resourceGroup().location
param app_service_plan_name string = 'thomas-test-123-asp'
param app_service_name string = 'thomas-test-123-web'
param dotnet_version string = '8.0'
resource app_service_plan 'Microsoft.Web/serverfarms@2024-04-01' = {
name: app_service_plan_name
location: location
kind: 'linux'
sku: {
name: 'B1'
tier: 'Basic'
}
properties: {
reserved: true
}
}
resource app_service 'Microsoft.Web/sites@2024-04-01' = {
name: app_service_name
location: location
kind: 'app,linux'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: app_service_plan.id
siteConfig: {
linuxFxVersion: 'DOTNETCORE|${dotnet_version}'
appSettings: []
}
}
}