检索虚拟网络中的所有子网ID,并为每一个创建一个MySQL VNET安全规则 [英] Retrieve all subnet ID's in a virtual network and create a MySQL VNET security rule for each one
问题描述
嗨
请原谅我对PowerShell缺乏知识和习惯.
Please forgive my lack of PowerShell knowledge and noobiness.
我需要为Azure MySQL服务器实例创建127个VNET安全规则.虚拟网络位于同一区域的不同资源组中,因此我需要指定子网ID,而不仅仅是名称.我可以检索子网名称和 通过执行以下操作来获取ID
I need to create 127 VNET security rules for an Azure MySQL server instance. The virtual network is located in a different resource group in the same region so I need to specify the subnet ID rather than just the name. I can retrieve the subnet names and ID's by doing the following
$ vnet = Get-AzureRmVirtualNetwork-名称"some-vnet"; -ResourceGroupName某些资源组"
$ name = $ vnet.Subnets.Name
$vnet = Get-AzureRmVirtualNetwork -Name "some-vnet" -ResourceGroupName "some-resource-group"
$name = $vnet.Subnets.Name
和
$ vnet = Get-AzureRmVirtualNetwork-名称"some-vnet"; -ResourceGroupName某些资源组"
$ id = $ vnet.Subnets.Id
$vnet = Get-AzureRmVirtualNetwork -Name "some-vnet" -ResourceGroupName "some-resource-group"
$id = $vnet.Subnets.Id
规则名称必须是$ name中子网的名称,然后映射到$ id中的子网ID.
The rule names need to be the name of the subnets which are in $name which then map to the subnet ID in $id.
我猜我需要一个Foreach循环来创建规则,但是我在为$ name和$ id中的每个值执行该操作方面很挣扎.
I am guessing i need a Foreach loop to create the rules but I am struggling with how you would do that for each value in $name and $id.
非常感谢您的帮助.
在此先感谢
Andrew
推荐答案
for (
i = 1;
i -le 127;i -le 127;
这篇关于检索虚拟网络中的所有子网ID,并为每一个创建一个MySQL VNET安全规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!