gpt4 book ai didi

azure - 尝试通过 bicep 获取 Azure DNS 入站终结点的 IP 地址

转载 作者:行者123 更新时间:2023-12-02 06:35:09 25 4
gpt4 key购买 nike

我目前正在进行 Azure 部署,但遇到了不便。我需要获取 dns Inboud 端点的 IP 地址。该资源已经存在。我可以像这样引用资源:

param dnsInboundEndpointName string
resource dnsInboundEndpoint 'Microsoft.Network/dnsResolvers/inboundEndpoints@2022-07-01' existing = {
name: dnsInboundEndpointName
}

我想在创建这样的防火墙策略时使用它(稍微简化):

resource firewallPolicy 'Microsoft.Network/firewallPolicies@2022-09-01' = {
name: azureFirewallPolicyName
location: location
properties: {
dnsSettings: {
enableProxy: true
servers: [dnsInboundEndpoint.properties.ipConfigurations[0].privateIpAddress]
}
sku: {
tier: azureFirewallPolicySku
}
}
}

现在,当我尝试部署此程序时,出现以下错误:

'The template resource 'xxx' at line '1' and column '1359' is not valid: The language expression property array index '1' is out of bounds.

我尝试创建这样的参数:

param test string = dnsInboundEndpoint.properties.ipConfigurations[0].privateIpAddress

还有一个像这样的变量:

var dnsInboundEndpointIP = {
ip: dnsInboundEndpoint.properties.ipConfigurations[0].privateIpAddress
}

但我不断收到此错误。

我想知道如何引用 DNS 入站端点的 IP 地址。

最佳答案

您缺少 dnsResolver 资源的名称。 InboundEndpoints是子资源,需要指定父资源:

param dnsResolverName string
param dnsInboundEndpointName string
...

// Get a reference to the dns resolver resource
resource dnsResolver 'Microsoft.Network/dnsResolvers@2022-07-01' existing = {
name: dnsResolverName
}

// Get a reference to the inbound rule
resource dnsInboundEndpoint 'Microsoft.Network/dnsResolvers/inboundEndpoints@2022-07-01' existing = {
name: dnsInboundEndpointName
parent: dnsResolver
}

// Create firewall policy
resource firewallPolicy 'Microsoft.Network/firewallPolicies@2022-09-01' = {
...
properties: {
dnsSettings: {
enableProxy: true
servers: [
dnsInboundEndpoint.properties.ipConfigurations[0].privateIpAddress
]
}
...
}
}

关于azure - 尝试通过 bicep 获取 Azure DNS 入站终结点的 IP 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76493195/

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