更改Azure网络接口的IP地址 [英] Change IP addresses of a Azure network interface

本文介绍了更改Azure网络接口的IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已要求我更改Azure网络接口IP地址.我了解可以很容易地通过门户或Powershell进行操作,如

I have been asked to change the Azure network interface IP addresses. I understand it can be easily done via portal or Powershell as described here.

但是,我想通过REST进行相同的操作.根据我的发现,只能通过REST( https://docs.microsoft.com/zh-cn/rest/api/virtualnetwork/networkinterfaceipconfigurations ),但是我看不到可以通过其关联/取消关联IP地址的终结点从网络接口.我是否正在忽略某些内容,或者目前尚不支持该功能?

However, I would like to the same operation via REST. According to my findings, it is only possible to retrieve the IP configuration of the network interface via REST(https://docs.microsoft.com/en-us/rest/api/virtualnetwork/networkinterfaceipconfigurations), but I don't see an endpoint through which I can associate/disassociate the IP addresses from the network interface. Am I overlooking something or it is not supported as of now?

推荐答案

要更改Azure网络接口IP地址,重要的一点是,网络接口必须始终至少分配有一个专用IPv4地址.所以正确的顺序是:

To change the Azure network interface IP addresses, one important thing is that a network interface must always have at least one private IPv4 address assigned to it. So the right sequence is:

  1. 使用新的IP地址创建一个新的IP配置;
  2. 按预期删除旧的IP配置.

您可以使用REST API:网络接口-创建或使用Update 来实现它,这是一个示例,我假设您的网络接口只有一个名为 ipconfig1 的IP配置,然后将REST API与下面的主体一起使用:

You can use the REST API: Network Interfaces - Create Or Update to achieve it, and here is an example, I assume your network interface has only one IP config named ipconfig1, then use the REST API with the body below:

{
  "name": "nicName",
  "id": "nicResourceId",
  "location": "region",
  "properties": {
    "provisioningState": "Succeeded",
    "ipConfigurations": [
        {
            "name": "ipconfig2",
            "properties": {
                "privateIPAllocationMethod": "Dynamic",
                "subnet": {
                    "id": "subnetResourceId"
                },
                "primary": true,
                "privateIPAddressVersion": "IPv4"
            }
        }
    ],
    "dnsSettings": {
      "dnsServers": [],
      "appliedDnsServers": []
    },
    "enableAcceleratedNetworking": true,
    "enableIPForwarding": false
  },
  "type": "Microsoft.Network/networkInterfaces"
}

完成后,您的网络接口将只有一个名为 ipconfig2 的IP配置,并带有新的IP地址.您还可以使用静态分配方法,并根据需要使用特殊的IP地址.

When it finishes, your network interface will have only one IP config named ipconfig2 with a new IP address. You can also use the static allocation method and use a special IP address as you want.

这篇关于更改Azure网络接口的IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆