gpt4 book ai didi

azure - 二头肌 : merge objects to avoid redundancy

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

我在二头肌脚本中定义了多个应用服务。对于每一个,我都使用配置资源来定义配置。

resource appSettings1 'Microsoft.Web/sites/config@2022-03-01' = {
parent: appService1
name: 'appsettings'
properties: {
CONFIG1: value1
CONFIG2: value2
COMMON_CONFIG1: commom1
COMMON_CONFIG2: commom2
}
}

resource appSettings2 'Microsoft.Web/sites/config@2022-03-01' = {
parent: appService2
name: 'appsettings'
properties: {
CONFIG3: value3
CONFIG4: value4
COMMON_CONFIG1: commom1
COMMON_CONFIG2: commom2
}
}

应用服务中有很多通用设置。有没有一种方法可以让我只定义一次通用设置并将它们注入(inject)到每个配置中,这样我就不必在每个应用程序服务中定义相同的设置?不知怎的,像这样:

var commomSettings: {
COMMON_CONFIG1: commom1
COMMON_CONFIG2: commom2
}

resource appSettings1 'Microsoft.Web/sites/config@2022-03-01' = {
parent: appService1
name: 'appsettings'
properties: {
CONFIG1: value1
CONFIG2: value2
...commonSettings //somehow inject commonSettings
}
}

最佳答案

是的,您走在正确的道路上,您可以使用union合并对象的函数:

var commomSettings = {
COMMON_CONFIG1: commom1
COMMON_CONFIG2: commom2
}

resource appSettings1 'Microsoft.Web/sites/config@2022-03-01' = {
parent: appService1
name: 'appsettings'
properties: union(commomSettings, {
CONFIG1: value1
CONFIG2: value2
}
)
}

关于azure - 二头肌 : merge objects to avoid redundancy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76063032/

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