快速入门:使用 Azure CLI 创建公共 IP 地址Quickstart: Create a public IP address using Azure CLI

本文介绍了如何使用 Azure CLI 来创建公共 IP 地址。This article shows you how to create a public IP address resource using Azure CLI. 若要详细了解这可能关联到哪些资源,以及基本 SKU 和标准 SKU 之间的差异和其他相关信息,请参阅公共 IP 地址For more information on which resources this can be associated to, the difference between Basic and Standard SKU, and other related information, please see Public IP addresses. 对于此示例,我们只重点介绍 IPv4 地址;有关 IPv6 地址的详细信息,请参阅适用于 Azure VNet 的 IPv6For this example, we will focus on IPv4 addresses only; for more information on IPv6 addresses, see IPv6 for Azure VNet.

先决条件Prerequisites

  • 如果需要,请安装 Azure CLI 来运行 CLI 参考命令。If you prefer, install the Azure CLI to run CLI reference commands.

    • 如果使用的是本地安装,请使用 az login 命令登录到 Azure CLI。If you're using a local installation, sign in to the Azure CLI by using the az login command. 若要完成身份验证过程,请遵循终端中显示的步骤。To finish the authentication process, follow the steps displayed in your terminal. 有关其他登录选项,请参阅登录 Azure CLIFor additional sign-in options, see Sign in with the Azure CLI.

    • 出现提示时,请在首次使用时安装 Azure CLI 扩展。When you're prompted, install Azure CLI extensions on first use. 有关扩展详细信息,请参阅使用 Azure CLI 的扩展For more information about extensions, see Use extensions with the Azure CLI.

    • 运行 az version 以查找安装的版本和依赖库。Run az version to find the version and dependent libraries that are installed. 若要升级到最新版本,请运行 az upgradeTo upgrade to the latest version, run az upgrade.

  • 本文需要 Azure CLI 2.0.28 或更高版本。This article requires version 2.0.28 or later of the Azure CLI.

备注

请先运行 az cloud set -n AzureChinaCloud 更改云环境,然后才能在 Azure 中国中使用 Azure CLI。Before you can use Azure CLI in Azure China , please run az cloud set -n AzureChinaCloud first to change the cloud environment. 若要切换回 Azure 公有云,请再次运行 az cloud set -n AzureCloudIf you want to switch back to Azure Public Cloud, run az cloud set -n AzureCloud again.

创建资源组Create a resource group

Azure 资源组是在其中部署和管理 Azure 资源的逻辑容器。An Azure resource group is a logical container into which Azure resources are deployed and managed.

使用 az group create 在 chinaeast2 位置创建名为“myResourceGroup”的资源组 。Create a resource group with az group create named myResourceGroup in the chinaeast2 location.

  az group create \
    --name myResourceGroup \
    --location chinaeast2

创建公共 IPCreate public IP


备注

以下命令适用于 API 版本 2020-08-01 或更高版本。The following command works for API version 2020-08-01 or later. 有关当前正在使用的 API 版本的详细信息,请参阅资源提供程序和类型For more information about the API version currently being used, please refer to Resource Providers and Types.

使用 az network public-ip create 在 myResourceGroup 中创建一个标准公共 IP 地址作为名为 myStandardPublicIP 的非区域性资源 。Use az network public-ip create to create a standard public IP address as a non-zonal resource named myStandardPublicIP in myResourceGroup.

  az network public-ip create \
    --resource-group myResourceGroup \
    --name myStandardPublicIP \
    --sku Standard

此选择在所有区域均有效,并且目前在 Azure 中国区域中,这是标准公共 IP 地址的默认选择。This selection is valid in all regions and is the default selection for Standard Public IP addresses in Azure China regions currently.

其他信息Additional information

若要更详细地了解以上所列各个变量,请参阅管理公共 IP 地址For more details on the individual variables listed above, please see Manage public IP addresses.

后续步骤Next steps