【发布时间】:2021-11-24 20:04:15
【问题描述】:
我正在尝试通过在我的main.bicep 文件中调用的Network/trafficManagerProfiles.bicep 模块添加新的流量管理器配置文件。
这很好用。
main.bicep 文件正在使用它们自己的小模块创建多个功能应用程序,调用方式类似这样
module functionAppModule 'Web/functions.bicep' = {
dependsOn: [
appServicePlanModule
webApiStorageAccount
]
name: 'functionAppModule'
params: {
environmentName: environmentName
systemName: systemName
azureRegion: azureRegion
appServicePlanId: appServicePlanModule.outputs.id
}
}
现在我正在尝试将我的 Web 应用程序 (Azure Functions) 的必要端点添加到流量管理器配置文件中,using the endpoints property 也可以这样做。
但是,这意味着我需要向此文件添加一个参数,以接受包含有关我的应用服务的所有信息的对象数组,或者我需要在此处解决它们(通过使用 existing 关键字检索实例)。这听起来不像是实现它的方式,因为所有这些资源都已在 main.bicep 文件中可用/引用。
流量管理器配置文件模块现在如下所示:
param systemName string
@allowed([
'dev'
'test'
'acc'
'prod'
])
param environmentName string
param relativeLiveEndpoint string = '/api/Live'
var trafficManagerProfileName = '${systemName}${environmentName}'
resource trafficManagerProfile 'Microsoft.Network/trafficmanagerprofiles@2018-08-01' = {
name: trafficManagerProfileName
location: 'global'
properties: {
allowedEndpointRecordTypes: [
'DomainName'
]
dnsConfig: {
relativeName: trafficManagerProfileName
ttl: 60
}
profileStatus: 'Enabled'
trafficRoutingMethod: 'Performance'
monitorConfig: {
profileMonitorStatus: 'Online'
protocol: 'HTTPS'
port: 443
path: relativeLiveEndpoint
timeoutInSeconds: 10
intervalInSeconds: 30
toleratedNumberOfFailures: 3
}
endpoints: [
{
id: 'the resource id'
name: 'the resource name'
type: 'the resource type'
properties: {
endpointStatus: 'Enabled'
endpointMonitorStatus: 'Online'
targetResourceId: 'the resource id'
target: 'mysite.azurewebsites.net'
endpointLocation: 'West Europe'
weight: 1
priority: 1
}
}
// All other app services
]
}
}
根据 Stack Overflow 上的一些答案,endpoints 也可以通过 ARM 模板中的子资源创建(类似于 Microsoft.Network/trafficmanagerprofiles/endpoints),但是,这在 Bicep 中似乎不可用(或者只是在自动完成中不可用)。
我想要在我的main.bicep 文件中做类似的事情,因为这样我可以引用我想要添加的所有应用服务。
var trafficManagerProfileEndpoints 'Microsoft.Network/trafficmanagerprofiles/endpoints@2050-01-01` = {
name: '${trafficManagerProfile.Name}/endpoints'
endpoints: [
// All of my endpoints
]
}
与通过Microsoft.Web/sites/config@2020-12-01 获得的应用服务中的配置设置有些相似。
对此有什么想法吗?
【问题讨论】:
标签: azure azure-resource-manager azure-traffic-manager azure-bicep