首页 > 解决方案 > Java Azure SDK,如何删除网络接口中的辅助 IP?

问题描述

我正在尝试删除网络接口中的辅助 IP,但找不到使用 Azure java SDK 的方法。可能吗?

在此处输入图像描述

在此处输入图像描述

标签: javaazurenetworkinginterface

解决方案


关于这个问题,请参考下面的cdoe

创建服务主体并将 Azure RABC 角色分配给Contributorsp

开发工具包

<dependency>
      <groupId>com.microsoft.azure</groupId>
      <artifactId>azure</artifactId>
      <version>1.38.1</version>
    </dependency>

代码

 String clientId="232a1***";
        String clientSecret="?****";
        String tenant="e***";
        String subId="e*****";
        ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(clientId,
                tenant,
                clientSecret,
                AzureEnvironment.AZURE);

        Azure azure= Azure.configure()
                .withLogLevel(LogLevel.BODY_AND_HEADERS)
                .authenticate(credentials)
                .withSubscription(subId);

        NetworkInterface nic = azure.networkInterfaces().getByResourceGroup("andywin7","testnic");

        nic.update().withoutIPConfiguration("ipconfig2")
                .apply();

运行代码之前 在此处输入图像描述

运行代码后 在此处输入图像描述


推荐阅读