3.9. 为 RHEL 镜像配置 Azure 资源
Azure 资源是基于云的资源管理的基本服务,如计算、网络、存储。在上传 VHD 文件并创建 Azure 镜像之前,您需要完成 Azure 资源配置。
先决条件
- 您已安装了 Azure CLI。详情请参阅 安装 Azure CLI。
- 您已完成了 将 RHEL 镜像转换为 Azure 磁盘镜像 的过程。
流程
使用 Azure 凭证验证您的主机并登录:
$ az login要从浏览器登录,请通过 CLI 在浏览器中打开 Azure 登录页面。详情请参阅 使用浏览器登录。
在 Azure 区域中创建资源组:
$ az group create --name <resource-group> --location <azure-region>示例:
[clouduser@localhost]$ az group create --name azrhelclirsgrp --location southcentralus { "id": "/subscriptions//resourceGroups/azrhelclirsgrp", "location": "southcentralus", "managedBy": null, "name": "azrhelclirsgrp", "properties": { "provisioningState": "Succeeded" }, "tags": null }创建一个具有有效库存保留单元(SKU)类型的存储帐户。详情请查看 SKU 类型 :
$ az storage account create -l <azure-region> -n <storage-account-name> -g <resource-group> --sku <sku_type>示例:
$ az storage account create -l southcentralus -n azrhelclistact -g azrhelclirsgrp --sku Standard_LRS { "accessTier": null, "creationTime": "2017-04-05T19:10:29.855470+00:00", "customDomain": null, "encryption": null, "id": "/subscriptions//resourceGroups/azrhelclirsgrp/providers/Microsoft.Storage/storageAccounts/azrhelclistact", "kind": "StorageV2", "lastGeoFailoverTime": null, "location": "southcentralus", "name": "azrhelclistact", "primaryEndpoints": { "blob": "https://azrhelclistact.blob.core.windows.net/", "file": "https://azrhelclistact.file.core.windows.net/", "queue": "https://azrhelclistact.queue.core.windows.net/", "table": "https://azrhelclistact.table.core.windows.net/" }, "primaryLocation": "southcentralus", "provisioningState": "Succeeded", "resourceGroup": "azrhelclirsgrp", "secondaryEndpoints": null, "secondaryLocation": null, "sku": { "name": "Standard_LRS", "tier": "Standard" }, "statusOfPrimary": "available", "statusOfSecondary": null, "tags": {}, "type": "Microsoft.Storage/storageAccounts" }显示存储帐户详情:
$ az storage account show-connection-string -n <storage_account_name> -g <resource_group>示例:
$ az storage account show-connection-string -n azrhelclistact -g azrhelclirsgrp { "connectionString": "DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net;AccountName=azrhelclistact;AccountKey=NreGk...==" }通过导出现有连接字符串设置环境变量,来将系统连接到存储帐户:
$ export AZURE_STORAGE_CONNECTION_STRING="<storage_connection_string>"示例:
$ export AZURE_STORAGE_CONNECTION_STRING="DefaultEndpointsProtocol=https;EndpointSuffix=core.windows.net;AccountName=azrhelclistact;AccountKey=NreGk...=="创建存储容器:
$ az storage container create -n <container_name>示例:
$ az storage container create -n azrhelclistcont { "created": true }创建虚拟网络:
$ az network vnet create -g <resource group> --name <vnet_name> --subnet-name <subnet_name>示例:
$ az network vnet create --resource-group azrhelclirsgrp --name azrhelclivnet1 --subnet-name azrhelclisubnet1 { "newVNet": { "addressSpace": { "addressPrefixes": [ "10.0.0.0/16" ] }, "dhcpOptions": { "dnsServers": [] }, "etag": "W/\"\"", "id": "/subscriptions//resourceGroups/azrhelclirsgrp/providers/Microsoft.Network/virtualNetworks/azrhelclivnet1", "location": "southcentralus", "name": "azrhelclivnet1", "provisioningState": "Succeeded", "resourceGroup": "azrhelclirsgrp", "resourceGuid": "0f25efee-e2a6-4abe-a4e9-817061ee1e79", "subnets": [ { "addressPrefix": "10.0.0.0/24", "etag": "W/\"\"", "id": "/subscriptions//resourceGroups/azrhelclirsgrp/providers/Microsoft.Network/virtualNetworks/azrhelclivnet1/subnets/azrhelclisubnet1", "ipConfigurations": null, "name": "azrhelclisubnet1", "networkSecurityGroup": null, "provisioningState": "Succeeded", "resourceGroup": "azrhelclirsgrp", "resourceNavigationLinks": null, "routeTable": null } ], "tags": {}, "type": "Microsoft.Network/virtualNetworks", "virtualNetworkPeerings": null } }
后续步骤