- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我目前正在使用一个解决方案,该解决方案使用通过 ARM/Bicep 部署的 Azure 应用程序网关。随着时间的推移,会部署使用此 AppGw 的其他应用程序,因此在部署时通过 Az CLI(在中央基础设施 IaC 管道/流程之外)为这些应用程序创建规则/后端池/监听器。当谈到重新部署/更新中央 AppGw 时,我遇到了 ARM/Bicep 模板覆盖所有这些额外添加内容的经典问题,因为 AppGw 是单个资源,并且更改不在 ARM/Bicep 文件中已删除。
我过去通过检查 AppGw 是否存在、输出现有规则/池/等来解决这个问题。然后在重新部署之前将它们合并到 ARM/Bicep JSON 中。这工作得很好,但 AppGw 现在变得如此之大/复杂,以至于我在通过 Azure Devops 构建管道部署更新时遇到了 Bash 字符限制。因此,我正在寻找更好的方法来处理这个问题。我还尝试将现有配置输出到文件并通过 Azure Bicep 中的文件加载进行摄取,但我需要使用不同的配置在全局部署多个 AppGw,因此由于 Bicep 中的编译时文件引用限制,这对我不起作用.
我需要确保以某种方式遵守我的 AppGw 基线模板文件(该文件设置 TLS 级别或诊断设置等核心内容),同时不会覆盖单独部署过程中发生的修改。
我的问题是,我是否可以将现有 AppGw 的状态与我的基线模板合并/合并,可以使用 Azure Bicep,也可以重新工具到 Pulumi/Terraform 之类的东西(如果这会公开功能)。我想到的方法是:
我知道,但没有经验,Pulumi 的忽略更改和转换的概念。我不确定这是否涵盖了这里的用例。我在这里试图实现的目标可能与这些声明性语言的目的相冲突,但我只是想看看其他人是否有任何想法。
提前非常感谢!
最佳答案
使用 Bicep,如果应用程序网关已存在,您始终可以检索现有配置。以下是使用 httpListeners
的示例。
您可以像这样定义 app-gateway.bicep
模块:
param appGatewayName string
param location string = resourceGroup().location
...
param httpListeners array
resource appGateway 'Microsoft.Network/applicationGateways@2020-11-01' = {
name: appGatewayName
location: location
...
properties: {
...
httpListeners: httpListeners
}
}
然后从您的 main.bicep
文件中,使用默认或现有配置:
param appGateWayExists bool
param appGatewayName string
...
// Get existing app gateway if existing
resource existing 'Microsoft.Network/applicationGateways@2020-11-01' existing = if (appGateWayExists) {
name: appGatewayName
}
// Deploy app gateway
module appgateway './app-gateway.bicep' = {
name: 'app-gateway'
params: {
appGatewayName: appGatewayName
...
// Use existing configuration if exists
httpListeners: appGateWayExists ? existing.properties.httpListeners : [
{
// default listener configuration
}
]
}
}
然后你可以像这样调用它:
$appGatewayName = "<app-gateway-name>"
$appGatewayExists = (az resource list --name "$appGatewayName" --query '[].[id]' | ConvertFrom-Json).Length -gt 0
az deployment group create `
--resource-group "<resource-group-name>" `
...
--parameters `
appGateWayExists=$appGatewayExists `
appGatewayName="$appGatewayName" `
...
关于azure - 我可以将 Azure 资源的现有状态与 Azure Bicep 或 Pulumi 文件合并吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72991904/
我能够使用最新的 Bicep 版本 0.4 创建应用服务计划和应用服务。 resource myAppServicePlan 'Microsoft.Web/serverfarms@2021-01-01
我有一个二头肌文件,应该创建一个虚拟网络网关。我通过创建虚拟网络的单独二头肌文件将其分解。我真正应该做的是有一个用于 vnet 创建的模块和另一个用于虚拟网络网关的模块,因为 bicep 对我来说是新
我正在尝试使用 bicep 将 apim 后端资源部署到现有 apim 实例中。这是我的 apim mdoule 的相关部分: resource apim 'Microsoft.ApiManageme
我想生成一个二头肌来构建逻辑应用程序。其样板是 resource logicApp 'Microsoft.Logic/workflows@2019-05-01' = { name: 'lapp-$
像往常一样与二头肌文档碰撞。我似乎找不到任何有关如何向自动化帐户 Runbook 的作业计划添加参数的帮助。 MS 的示例是 name: 'string' parent: resourceSy
我的情况是,我有一个公司列表,以及一个我想在我的二头肌文件中配对的队列列表。我想使用结果将队列添加到服务总线命名空间。 这是队列数组的示例: `var queues = [ 'first-queu
在二头肌中,我有一个主要的二头肌,它会调用 部署应用服务的模块 部署托管身份的模块 应用程序服务模块如下所示,它使用用户分配的托管 ID 的输出,并在应用程序服务的身份中分配: 主要二头肌 modul
我有一个应用程序,它有一个二头肌文件(用于部署 azure 应用程序服务),它调用另一个存储库中的模板模块(应用程序服务模板)。模板模块引用同一存储库中的多个模块。它调用一个用于应用服务计划的模块,一
尝试将托管标识分配给同一租户中单独订阅中的资源组。我可以通过 Azure 门户实现此目的。我的 Main.bicep,类似这样: targetScope = 'subscription' module
我目前正在尝试手动将现有 ARM 模板转换为二头肌,因为自动反编译方法失败。 现有模板包含以下变量: "environmentSize": { "dev": "small",
我正在运行二头肌 0.4.1318。 我有一个“主”二头肌模块,它调用子模块来配置数据工厂: var adfName = 'adf-ctaxrebate-${envPlusSuffix}-${form
我有一个 Azure Bicep 模板,用于部署存储帐户和容器。但是,当我重命名容器或注释掉模板中的容器资源时,不会触发删除操作。相反,它会创建一个新容器并且不会删除旧容器。有什么想法为什么会发生这种
我想创建一个 Azure 容器应用程序,该应用程序从位于不同订阅中的现有 Azure 容器应用程序注册表中提取其镜像。 我的主要二头肌: 创建用户分配的托管身份 将托管身份的 ACR Pull RBA
我刚开始使用 Azure 二头肌。我正在尝试使用以下二头肌文件部署一个简单的应用程序服务计划/应用程序服务: resource azBicepAsp1 'Microsoft.Web/serverfar
我想要一个可以向现有应用服务(本例中为函数应用)添加一组固定的 IP 限制规则的模块。 我在 main.bicep 中添加了对“ipSecurityRestrictions”模块的调用,如下所示: m
如何使用 bicep 更新字典对象,例如:原始字典对象: var dict = { 'a': {} } 我现在有一个数组:['b', 'c'],我想更新 dict 对象,例如: { 'a':
我需要: 创建数据工厂 创建存储帐户 创建函数应用 将数据工厂的角色分配添加到存储帐户 将函数应用的角色分配添加到存储帐户 数据工厂是在与“主”二头肌不同的模块中创建的。这是为了防止“主”模板太大而难
我正在尝试引用现有的二头肌模块作为另一个资源的父级。 module vnethub 'modules/vnet/vnet.bicep' = { scope: resourceGroup(rg.na
我正在尝试创建一个二头肌模板来根据条件部署具有 1 个或 2 个 NIC 的虚拟机。 有人知道是否有一种方法可以在属性定义中使用条件语句来部署虚拟机网卡吗?似乎资源定义中不允许使用 if 函数,并且由
我正在尝试使用以下代码创建一个简单的应用服务计划。 param Location string = 'eastus' resource appServicePlan1 'Microsoft.Web/s
我是一名优秀的程序员,十分优秀!