0

使用 CLI 从同一订阅中的存储帐户中的 VHD 文件创建托管磁盘时面临问题。

我已使用以下脚本将托管磁盘增量快照从西区复制/复制到东区。


#Provide the name of your resource group where snapshot is created
sourceResourceGroupName=""
drSnapshotResourceGroupName=""

#Provide storage account name where you want to copy the snapshot.
drSnapshotStorageAccountName=""

#Name of the storage container where the downloaded snapshot will be stored
storageContainerName=""

#Provide Shared Access Signature (SAS) expiry duration in seconds e.g. 3600.
#Know more about SAS here: https://docs.microsoft.com/en-us/azure/storage/storage-dotnet-shared-access-signature-part-1
sasExpiryDuration=36000

#Provide the key of the storage account where you want to copy snapshot.
storageAccountKey=$(az storage account keys list -g $drSnapshotResourceGroupName -n $drSnapshotStorageAccountName --query [0].value -otsv)

SNAPSHOT_NAMES=$(az snapshot list -g $sourceResourceGroupName --query "[?tags.COMPONENT== 'database'].name" --output tsv)

for snapshot_name in $SNAPSHOT_NAMES
do
        #Provide the snapshot name
        snapshotName=$snapshot_name

        #Provide the name of the VHD file to which snapshot will be copied.
        destinationVHDFileName="$snapshot_name.vhd"

     
        sas=$(az snapshot grant-access --resource-group $sourceResourceGroupName --name $snapshotName \
                --duration-in-seconds $sasExpiryDuration --query [accessSas] -o tsv)

        az storage blob incremental-copy start --destination-blob $destinationVHDFileName \
        --destination-container $storageContainerName --account-name $drSnapshotStorageAccountName \
        --account-key $storageAccountKey --source-uri $sas
done

我正在尝试使用 az cli 使用以下脚本从东区复制的 vhd 创建托管磁盘。

#Provide the name of your resource group where snapshot is created
drSnapshotResourceGroupName=""

#Provide the name of your resource group.
#Ensure that resource group is already created
drResourceGroupName=""

#Provide storage account name where you want to copy the snapshot.
drSnapshotStorageAccountName=""

#Name of the storage container where the downloaded snapshot will be stored
storageContainerName=""

#Provide the name of the Managed Disk
diskName=disknametocreatefromvhd

#Provide the size of the disks in GB. It should be greater than the VHD file size.
diskSize=512


#Provide the URI of the VHD file that will be used to create Managed Disk.
# VHD file can be deleted as soon as Managed Disk is created.
# e.g. https://contosostorageaccount1.blob.core.windows.net/vhds/contosovhd123.vhd
vhdUri=https://xxxxxxxxxxxxxxxxxx.blob.core.windows.net/asdf/abcd.vhd

#Provide the storage type for the Managed Disk. Premium_LRS or Standard_LRS.
storageType=Premium_LRS

#Provide the Azure location (e.g. westus) where Managed Disk will be located.
location=eastus

echo "Creating managed disk from the VHD file"

#Create the Managed disk from the VHD file
az disk create --resource-group ${drResourceGroupName} --name ${diskName} \
                --sku $storageType --location $location \
                --size-gb $diskSize --source $vhdUri

得到下面提到的 az disk create 中的错误。

request failed: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/32d45ca1-b2dc-4370-a618-85e7756da78f/resourceGroups/DR02-Recovery/providers/Microsoft.Compute/disks/draas-snapshot-database-vm0-osdisk-asdf?api-version=2019-11-01 (Caused by ResponseError('too many 500 error responses',))

在此处添加完整的调试输出。

Command arguments: ['disk', 'create', '--resource-group', 'RG_NAME', '--name', 'abcd-osdisk', '--sku', 'Premium_LRS', '--location', 'eastus', '--size-gb', '512', '--source', 'https://storageaccountname.blob.core.windows.net/asdf/abcd-osdisk.vhd', '--debug']
Event: Cli.PreExecute []
Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7fa05b4d5d90>, <function OutputProducer.on_global_arguments at 0x7fa05b2aad90>, <function CLIQuery.on_global_arguments at 0x7fa05b052048>]
Event: CommandInvoker.OnPreCommandTableCreate []
Installed command modules ['acr', 'acs', 'advisor', 'ams', 'apim', 'appconfig', 'appservice', 'aro', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'configure', 'consumption', 'container', 'cosmosdb', 'deploymentmanager', 'dla', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'interactive', 'iot', 'iotcentral', 'keyvault', 'kusto', 'lab', 'managedservices', 'maps', 'monitor', 'natgateway', 'netappfiles', 'network', 'policyinsights', 'privatedns', 'profile', 'rdbms', 'redis', 'relay', 'reservations', 'resource', 'role', 'search', 'security', 'servicebus', 'servicefabric', 'signalr', 'sql', 'sqlvm', 'storage', 'util', 'vm']
Loaded module 'acr' in 0.007 seconds.
Loaded module 'acs' in 0.008 seconds.
Loaded module 'advisor' in 0.001 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'ams' in 0.006 seconds.
Loaded module 'apim' in 0.002 seconds.
Loaded module 'appconfig' in 0.003 seconds.
Loaded module 'appservice' in 0.223 seconds.
Loaded module 'aro' in 0.005 seconds.
Loaded module 'backup' in 0.004 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'batch' in 0.028 seconds.
Loaded module 'batchai' in 0.003 seconds.
Loaded module 'billing' in 0.001 seconds.
Loaded module 'botservice' in 0.003 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'cdn' in 0.005 seconds.
Loaded module 'cloud' in 0.001 seconds.
Loaded module 'cognitiveservices' in 0.002 seconds.
Loaded module 'configure' in 0.001 seconds.
Loaded module 'consumption' in 0.002 seconds.
Loaded module 'container' in 0.002 seconds.
Loaded module 'cosmosdb' in 0.008 seconds.
Loaded module 'deploymentmanager' in 0.002 seconds.
Loaded module 'dla' in 0.004 seconds.
Loaded module 'dls' in 0.003 seconds.
Loaded module 'dms' in 0.002 seconds.
Loaded module 'eventgrid' in 0.002 seconds.
Loaded module 'eventhubs' in 0.004 seconds.
Loaded module 'extension' in 0.001 seconds.
Loaded module 'feedback' in 0.001 seconds.
Loaded module 'find' in 0.001 seconds.
Loaded module 'hdinsight' in 0.002 seconds.
Loaded module 'interactive' in 0.000 seconds.
Loaded module 'iot' in 0.005 seconds.
Loaded module 'iotcentral' in 0.001 seconds.
Loaded module 'keyvault' in 0.006 seconds.
Loaded module 'kusto' in 0.002 seconds.
Loaded module 'lab' in 0.003 seconds.
Loaded module 'managedservices' in 0.002 seconds.
Loaded module 'maps' in 0.001 seconds.
Loaded module 'monitor' in 0.009 seconds.
Loaded module 'natgateway' in 0.001 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'netappfiles' in 0.003 seconds.
Loaded module 'network' in 0.035 seconds.
Loaded module 'policyinsights' in 0.003 seconds.
Loaded module 'privatedns' in 0.005 seconds.
Loaded module 'profile' in 0.001 seconds.
Loaded module 'rdbms' in 0.008 seconds.
Loaded module 'redis' in 0.002 seconds.
Loaded module 'relay' in 0.003 seconds.
Loaded module 'reservations' in 0.002 seconds.
Loaded module 'resource' in 0.011 seconds.
Loaded module 'role' in 0.004 seconds.
Loaded module 'search' in 0.001 seconds.
Loaded module 'security' in 0.004 seconds.
Loaded module 'servicebus' in 0.005 seconds.
Loaded module 'servicefabric' in 0.003 seconds.
Loaded module 'signalr' in 0.002 seconds.
Loaded module 'sql' in 0.011 seconds.
Loaded module 'sqlvm' in 0.002 seconds.
Event: CommandLoader.OnLoadCommandTable []
Loaded module 'storage' in 0.042 seconds.
Loaded module 'util' in 0.001 seconds.
Loaded module 'vm' in 0.042 seconds.
Loaded all modules in 0.560 seconds. (note: there's always an overhead with the first module loaded)
Event: CommandInvoker.OnPreCommandTableTruncate [<function AzCliLogging.init_command_file_logging at 0x7fa05aa09950>]
az_command_data_logger : command args: disk create --resource-group {} --name {} --sku {} --location {} --size-gb {} --source {} --debug
metadata file logging enabled - writing logs to '/home/Test/.azure/commands'.
Event: CommandInvoker.OnPreArgumentLoad [<function register_global_subscription_argument.<locals>.add_subscription_parameter at 0x7fa05aa2cae8>]
Event: CommandInvoker.OnPostArgumentLoad []
Event: CommandInvoker.OnPostCommandTableCreate [<function register_ids_argument.<locals>.add_ids_arguments at 0x7fa05a9e1bf8>, <function register_cache_arguments.<locals>.add_cache_arguments at 0x7fa05a9e1d08>]
Event: CommandInvoker.OnCommandTableLoaded []
Event: CommandInvoker.OnPreParseArgs [<function _documentdb_deprecate at 0x7fa05898b1e0>]
Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fa05b2aae18>, <function CLIQuery.handle_query_parameter at 0x7fa05b0520d0>, <function register_ids_argument.<locals>.parse_ids_arguments at 0x7fa05a9e1c80>, <function handler at 0x7fa0587e6bf8>]
Getting management service client client_type=ComputeManagementClient
msrest.universal_http.requests : Configuring retry: max_retries=4, backoff_factor=0.8, max_backoff=90
urllib3.connectionpool : Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool : http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2054
msrestazure.azure_active_directory : MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
urllib3.connectionpool : Starting new HTTP connection (1): localhost:50342
urllib3.connectionpool : http://localhost:50342 "POST /oauth2/token HTTP/1.1" 200 2054
msrestazure.azure_active_directory : MSI: Retrieving a token from http://localhost:50342/oauth2/token, with payload {'resource': 'https://management.core.windows.net/'}
msrest.http_logger : Request URL: 'https://management.azure.com/subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01'
msrest.http_logger : Request method: 'PUT'
msrest.http_logger : Request headers:
msrest.http_logger :     'Accept': 'application/json'
msrest.http_logger :     'Content-Type': 'application/json; charset=utf-8'
msrest.http_logger :     'accept-language': 'en-US'
msrest.http_logger :     'Content-Length': '461'
msrest.http_logger :     'User-Agent': 'python/3.6.10 (Linux-4.15.0-1089-azure-x86_64-with-debian-stretch-sid) msrest/0.6.9 cloud-shell/1.0 msrest_azure/0.6.3 azure-mgmt-compute/12.0.0 Azure-SDK-For-Python AZURECLI/2.8.0 (DEB)'
msrest.http_logger : Request body:
msrest.http_logger : {"location": "eastus", "tags": {}, "sku": {"name": "Premium_LRS"}, "properties": {"hyperVGeneration": "V1", "creationData": {"createOption": "Import", "storageAccountId": "/subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Storage/storageAccounts/storageaccountname", "sourceUri": "https://storageaccountname.blob.core.windows.net/asdf/abcd-osdisk.vhd"}, "diskSizeGB": 512}}
msrest.universal_http : Configuring redirects: allow=True, max=30
msrest.universal_http : Configuring request: timeout=100, verify=True, cert=None
msrest.universal_http : Configuring proxies: ''
msrest.universal_http : Evaluate proxies against ENV settings: True
urllib3.connectionpool : Starting new HTTPS connection (1): management.azure.com:443
urllib3.connectionpool : https://management.azure.com:443 "PUT /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 HTTP/1.1" 500 125
urllib3.util.retry : Incremented Retry for (url='/subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01'): Retry(total=3, connect=4, read=4, redirect=None, status=None)
urllib3.connectionpool : Retry: /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01
urllib3.connectionpool : Resetting dropped connection: management.azure.com
urllib3.connectionpool : https://management.azure.com:443 "PUT /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 HTTP/1.1" 500 125
urllib3.util.retry : Incremented Retry for (url='/subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01'): Retry(total=2, connect=4, read=4, redirect=None, status=None)

urllib3.connectionpool : Retry: /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01
urllib3.connectionpool : Resetting dropped connection: management.azure.com
urllib3.connectionpool : https://management.azure.com:443 "PUT /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 HTTP/1.1" 500 125
urllib3.util.retry : Incremented Retry for (url='/subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01'): Retry(total=1, connect=4, read=4, redirect=None, status=None)

urllib3.connectionpool : Retry: /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01
urllib3.connectionpool : Resetting dropped connection: management.azure.com
urllib3.connectionpool : https://management.azure.com:443 "PUT /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 HTTP/1.1" 500 125
urllib3.util.retry : Incremented Retry for (url='/subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01'): Retry(total=0, connect=4, read=4, redirect=None, status=None)


urllib3.connectionpool : Retry: /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01
urllib3.connectionpool : Resetting dropped connection: management.azure.com
urllib3.connectionpool : https://management.azure.com:443 "PUT /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 HTTP/1.1" 500 125
msrest.exceptions : Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 (Caused by ResponseError('too many 500 error responses',))


cli.azure.cli.core.util : request failed: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 (Caused by ResponseError('too many 500 error responses',))
request failed: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/32d45ba1-b2dc-4370-a618-85e7756da78f/resourceGroups/RG_NAME/providers/Microsoft.Compute/disks/abcd-osdisk?api-version=2019-11-01 (Caused by ResponseError('too many 500 error responses',))
Event: Cli.PostExecute [<function AzCliLogging.deinit_cmd_metadata_logging at 0x7fa05aa09b70>]
az_command_data_logger : exit code: 1
telemetry.save : Save telemetry record of length 5618 in cache
telemetry.check : Returns Positive.
telemetry.main : Begin creating telemetry upload process.
telemetry.process : Creating upload process: "/opt/az/bin/python3 /opt/az/lib/python3.6/site-packages/azure/cli/telemetry/__init__.py /home/vinayak/.azure"
telemetry.process : Return from creating process
telemetry.main : Finish creating telemetry upload process.
Command ran in 725.683 seconds (init: 0.048, invoke: 725.635)

4

1 回答 1

0

到目前为止,这是我对 Azure 增量快照的不同场景的发现。

  1. 第一个场景创建增量快照,是在同一区域创建磁盘。这在门户网站上是成功的,没有任何问题。

现在可以将此磁盘导出或复制到另一个区域。

  1. 第二种情况,使用 CLI 跨区域复制增量快照,这是成功的,但是我们无法使用此快照创建磁盘,因为支持这种复制增量快照的方法。

复制增量快照的唯一方法是使用快照 blob 和复制 blob,然后获取差异 PagesRanges 并使用 PutPages 应用更改。

然后拍摄备份 Page Blob 的快照并将其存储在存储帐户中。

查找有关使用增量快照进行备份的文档 https://docs.microsoft.com/en-us/azure/virtual-machines/windows/incremental-snapshots#incremental-snapshot-copy

而这个.Net代码的文档将增量快照复制到另一个区域

https://github.com/Azure-Samples/managed-disks-dotnet-backup-with-incremental-snapshots

使用 Azure CLI、PowerShell 或任何 SDK 将增量快照用作 DR/故障转移到另一个区域。

于 2020-07-13T05:55:10.763 回答