- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想将现有 NSG 添加到现有 VNet 子网。我尝试这样做:
@description('Name of nsg')
param nsgName string
@description('Name of vnet')
param vnetName string
@description('Name of subnet')
param subnetName string
resource nsg 'Microsoft.Network/networkSecurityGroups@2022-01-01' existing = {
name: nsgName
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2022-01-01' existing = {
name: '${vnetName}/${subnetName}'
}
resource nsgAttachment 'Microsoft.Network/virtualNetworks/subnets@2022-01-01' = {
name: '${vnetName}/${subnetName}'
properties: {
addressPrefix: subnet.properties.addressPrefix
networkSecurityGroup: {
id: nsg.id
}
}
}
不幸的是,我无法通过 Azure 门户上的审核/验证。它说:
{"code":"InvalidTemplate","message":"Deployment template validation failed: 'Circular dependency detected on resource: '/subscriptions/xxxxxxxxx-02eaf5d20f25/resourceGroups/bicepRG/providers/Microsoft.Network/virtualNetworks/myVnetName/subnets/api'. Please see https://aka.ms/arm-template/#resources for usage details.'."}
如何将 NSG 分配到现有 VNet 子网,或者如何消除此循环依赖错误
?
最佳答案
您必须使用 module更新子网:
// update-subnet.bicep
param vnetName string
param subnetName string
param properties object
// Get existing vnet
resource vnet 'Microsoft.Network/virtualNetworks@2022-01-01' existing = {
name: vnetName
}
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2022-01-01' = {
name: subnetName
parent: vnet
properties: properties
}
从你的 main 中,你可以像这样调用它:
// main.bicep
param nsgName string = 'thomastest-nsg2'
param vnetName string = 'thomastest-vnet'
param subnetName string = 'subnet1'
// Reference to nsg
resource nsg 'Microsoft.Network/networkSecurityGroups@2022-01-01' existing = {
name: nsgName
}
// Get existing vnet
resource vnet 'Microsoft.Network/virtualNetworks@2022-01-01' existing = {
name: vnetName
}
// Get existing subnet
resource subnet 'Microsoft.Network/virtualNetworks/subnets@2022-01-01' existing = {
name: subnetName
parent: vnet
}
// Update the subnet
module attachNsg 'update-subnet.bicep' = {
name: 'update-vnet-subnet-${vnetName}-${subnetName}'
params: {
vnetName: vnetName
subnetName: subnetName
// Update the nsg
properties: union(subnet.properties, {
networkSecurityGroup: {
id: nsg.id
}
})
}
}
关于azure - 使用 Bicep 模板将 NSG 分配到 VNet 子网,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73568924/
我最近开始使用 azure 开发 terraform。作为其中的一部分,我尽可能多地浏览了文档来创建资源。在此我尝试创建 AKS 集群。我能够创建成功。但我有一些担忧(我觉得有错误,如果我错了请纠正)
我正在尝试编写一个脚本来自动为我们的生产 NSG 创建 NSG 规则。我很确定我有一些接近工作的东西,但我遇到的问题是 Get-AZNetworkSecurityGroup 命令返回一个字符串,因此我
出于安全目的,是否可以将 NSG 启用到云服务?我尝试创建一个 Vnet,但无法将 NSG 添加到我创建的 vnet,不确定是否可以这样做。 最佳答案 您无法将 NSG 分配给云服务。云服务是 Azu
我正在将现有的 Azure 经典 VM 迁移到基于资源管理器的新 VM,希望得到一些建议。 新架构将具有 负载均衡器绑定(bind)到公共(public) IP 1 个虚拟网络 1 个网络安全组 1
我正在致力于备份 Azure Stack 的 Azure 网络安全。 我已经使用了 Azure Powershell,并且使用该模块我可以导出 CSV 中的现有配置,并使用导出的 CSV 重新部署内容
我在创建 VNET/子网时遇到一些困难。我也在使用 ASE,为此我只能使用经典 VNET。 Azure 提供两种类型的 VNET。根据创建方式(通过 Azure 门户、xplat-cli、旧门户、po
我的要求很简单。我需要将 NSG 关联到包含我的应用程序网关的子网。 一旦将 NSG 关联到此子网,我就会收到连接超时错误。 根据 Microsoft 文档,我添加了端口范围 65503-65534
我在创建 VNET/子网时遇到一些困难。我也在使用 ASE,为此我只能使用经典 VNET。 Azure 提供两种类型的 VNET。根据创建方式(通过 Azure 门户、xplat-cli、旧门户、po
我的要求很简单。我需要将 NSG 关联到包含我的应用程序网关的子网。 一旦将 NSG 关联到此子网,我就会收到连接超时错误。 根据 Microsoft 文档,我添加了端口范围 65503-65534
我有一个关于云中客户服务器的网络问题。 我们仅使用标准 2012R2 虚拟机,其中通过 NSG 防火墙设置了一些端点,并且我们在网络前端有一个 LoadBalancer,其中一些端口转发到同一 VPC
正在处理自定义策略强制子网和 nsg 关联的项目。如果子网没有与其关联的 NSG,则无法配置。 使用 terraform 部署资源 - 资源组、VNET、NSG,在创建子网之前,我创建了与子网关联的
我现在使用 Azure NSG 仅允许受信任的 IP 访问我自己的 VNET 中的 Azure IaaS VM 上托管的后端服务。 我的问题是,IP白名单策略足够安全吗?我想知道黑客是否有可能将源IP
我终于正确设置了一个 azure 的 sftp 容器实例,但在为其配置安全性时遇到了困难(很像 here )。 我的基本流程是这样的: Azure 上的 PIP -> -> 使用 PIP 的负载均衡器
尝试创建策略以启用现有 NSG 的 NSG 流日志(如果处于禁用状态)。完成任务的任何建议或引用。提前致谢。 最佳答案 现在可以通过 Azure Policy 运行 { "mode": "All"
我正在向 NSG 添加一条安全规则,允许访问端口 4239,1128,1129。通过 Azure 门户,它可以工作。通过 Powershell,它拒绝。 我使用以下代码来获取 NSG、添加安全规则并更
尝试创建策略以启用现有 NSG 的 NSG 流日志(如果处于禁用状态)。完成任务的任何建议或引用。提前致谢。 最佳答案 现在可以通过 Azure Policy 运行 { "mode": "All"
我正在向 NSG 添加一条安全规则,允许访问端口 4239,1128,1129。通过 Azure 门户,它可以工作。通过 Powershell,它拒绝。 我使用以下代码来获取 NSG、添加安全规则并更
我想为我的 NSG 出站部分创建一组规则,以仅允许连接到 Azure 服务。有 article了解如何使用 PowerShell 实现此目的,但我将 Linux 与 Azure CLI 结合使用。 除
问题描述 对Azure上的虚拟机资源,需要进行安全管理。只有指定的IP地址才能够通过RDP/SSH远程到虚拟机上, 有如下几点考虑: 1) 使用Azure Policy服务,扫描订阅中全部的网络安
我正在使用 ARM 模板创建新的 NSG,并更新同一 ARM 模板中的子网。我希望能够通过“引用”获取子网地址前缀,但这样做时我总是检测到循环依赖关系。有什么办法解决吗?我的子网臂模板部分如下所示:
我是一名优秀的程序员,十分优秀!