Azure Bicep将App IP存储在字符串参数中。

huangapple go评论66阅读模式
英文:

Azure bicep store App Ip in string parameter

问题

我想将应用站点的出站 IP 存储在一个字符串参数中,以便稍后将 IP 拆分为数组使用,但我收到了“此符号无法在此引用。只有其他参数可以在参数默认值中引用”的消息,我不知道该如何继续。

有人能帮助我吗?以下是我的代码:

resource sitewww 'Microsoft.Web/sites@2022-03-01' = {
    name: 'sitewwwname'
    location: 'westeurope'
}

param variable string = sitewww.properties.outboundIpAddresses
param allowedIpAddresses array = split(variable, ',')

非常感谢!

英文:

I would like to store the outbound ip of an App site in a string parameter, so I could use it later to split the ips into an array, but I get the "this symbol cannot be referenced here. only other parameters can be referenced in parameter default values" message and I do not how to proceed

Can anyone help me? Here is my code:

resource sitewww 'Microsoft.Web/sites@2022-03-01' = {

name: 'sitewwwname'
location: 'westeurope'

}

param variable string = sitewww.properties.outboundIpAddresses
param allowedIpAddresses array = split(variable,',')

Thank you very much!

答案1

得分: 0

你希望在这里使用变量,而不是参数。

所以在你的资源下面的参数声明将会变成变量。

所以你的 Bicep 代码会变成:

resource sitewww 'Microsoft.Web/sites@2022-03-01' = {
  name: 'sitewwwname'
  location: 'westeurope'
}

var variable = sitewww.properties.outboundIpAddresses
var allowedIpAddresses = split(variable, ',')
英文:

You want to be using a variables here not a parameters.

So the param declarations below your resource would change to var

So your bicep above would be

resource sitewww 'Microsoft.Web/sites@2022-03-01' = {

name: 'sitewwwname'
location: 'westeurope'

}

var variable = sitewww.properties.outboundIpAddresses
var allowedIpAddresses = split(variable,',')

huangapple
  • 本文由 发表于 2023年3月15日 19:14:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75743948.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定