简体   繁体   English

Azure Powershell - 将私有 IP 地址分配给 NIC 时出现问题

[英]Azure Powershell - Problem with assigning private IP address to an NIC

Here is my script这是我的脚本

$my_vnet = Get-AzVirtualNetwork -Name <vnet_name>
$my_subnet = Get-AzVirtualNetworkSubnetConfig -Name <subnet_name> -VirtualNetwork $my_vnet
Add-AzNetworkInterfaceIpConfig -Name ext-ipconfig6 -NetworkInterface $my_nic - 
Subnet $my_subnet -PrivateIpAddress 10.0.0.6

There is no error when running the script.运行脚本时没有错误。 If I use the following command to check, I do see the IP object created.如果我使用以下命令进行检查,我确实看到创建了 IP object。

Get-AzNetworkInterfaceIpConfig -Name ext-ipconfig6 -NetworkInterface $my_nic
...
{
  "Name": "ext-ipconfig6",
  "PrivateIpAddress": "10.0.0.6",
  "PrivateIpAllocationMethod": "Static",
  "Subnet": {
    "Id": "blabla"
  },
  "Primary": false
}

However, I don't see it created on the portal.但是,我没有看到它在门户网站上创建。

Comparing with others created in the portal, I see other properties like Etag , Id , ProvisioningState , ...etc.与门户中创建的其他属性相比,我看到了其他属性,如EtagIdProvisioningState等。 Where did I do wrong...?我哪里做错了……? Thanks!谢谢!

You are just creating the Network Interface IP configuration and not setting it to the existing Network interface itself.您只是在创建网络接口 IP 配置,而不是将其设置为现有网络接口本身。

I tested the same script which resulted as below:我测试了相同的脚本,结果如下:

在此处输入图像描述 在此处输入图像描述

To fix the above you will have to add | Set-AzNetworkInterface要解决上述问题,您必须添加| Set-AzNetworkInterface | Set-AzNetworkInterface after the Add-AzNetworkInterfaceIpConfig command like below:Add-AzNetworkInterfaceIpConfig命令之后| Set-AzNetworkInterface ,如下所示:

$vnet = Get-AzVirtualNetwork -Name "ansuman-vnet" -ResourceGroupName "ansumantest" 
$nic= Get-AzNetworkInterface -Name "ansumannic01" -ResourceGroupName "ansumantest"
Add-AzNetworkInterfaceIpConfig -Name "IPConfig2" -NetworkInterface $nic -Subnet $vnet.Subnets[0]  -PrivateIpAddress "10.0.0.7" | Set-AzNetworkInterface

Output: Output:

在此处输入图像描述 在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure Powershell (Az模块) 公开IP地址 - Azure Powershell (Az module) get public IP address 在具有单个 NIC 的单个 GCE 实例上分配多个私有到公共映射 - Assigning multiple private-to-public mapping on a single GCE instance with a single NIC AWS - Fargate 任务的私有地址 static IP - AWS - Private static IP address for Fargate task 分配Elastic IP地址后,EC2实例无法再访问 - After assigning Elastic IP address, the EC2 instance is no longer accessible 将 gcp 计算机器上的固定私有地址 ip 与 terraform 相关联 - associate a fixed private ip address on gcp compute machine with terraform 目标 VPC 服务器 FROM 公共服务器的私有 IP 地址 - Target VPC server FROM the private IP address of a public server ARM 模板 - 从 a.network interface id 获取私有地址 ip - ARM Template - Get a private ip address from a network interface id 通过公共 IP 地址获取 Azure FQDN(DNS 名称) - Get Azure FQDN (DNS Name) by Public IP Address 为什么Azure保留一个su.net的前四个IP地址 - Why Azure reserves first four IP address of a subnet 是否可以为 azure 物联网中心提供 static 入站 IP 地址 - Is it possible to have a static inbound IP address for azure IoT hub
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM