gpt4 book ai didi

azure - 在主二头肌模板中添加 Azure 流量管理器端点作为子资源

转载 作者:行者123 更新时间:2023-12-02 06:24:39 27 4
gpt4 key购买 nike

我正在尝试通过 Network/trafficManagerProfiles.bicep 添加新的流量管理器配置文件我在 main.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 提供的内容有些相似用于应用服务中的配置设置。

对此有什么想法吗?

最佳答案

我刚刚以闪电般的速度浏览了你的问题,如果我不完全理解它,请原谅我,但看起来你需要再次将你的网络应用程序声明为资源,但作为现有资源。这使您可以从应用服务访问所需的所有 Prop 。

此博客解释了如何使用 Bicep 中的现有资源:https://hexmaster.nl/posts/bicep-existing/

关于azure - 在主二头肌模板中添加 Azure 流量管理器端点作为子资源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70102291/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com