Azure / azure-cli

Azure Command-Line Interface
MIT License
3.99k stars 2.96k forks source link

failed to create snapshot due to bad api #9233

Closed StellaZhou64 closed 5 years ago

StellaZhou64 commented 5 years ago

Tried to create snapshot with command below, but got error "Resource is not found" while the OS disk is there. And it seems to be related to bad api.

root@Ubuntu1710:~# az snapshot create --name centos-image-20190429140209_os_disk_snapshot --resource-group --source /subscriptions//resourceGroups//providers/Microsoft.Compute/disks/centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693 --output json --tags created_by=image-copy-extension --debug Command arguments: ['snapshot', 'create', '--name', 'centos-image-20190429140209_os_disk_snapshot', '--resource-group', '', '--source', '/subscriptions//resourceGroups//providers/Microsoft.Compute/disks/centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693', '--output', 'json', '--tags', 'created_by=image-copy-extension', '--debug'] Event: Cli.PreExecute [] Event: CommandParser.OnGlobalArgumentsCreate [<function CLILogging.on_global_arguments at 0x7fbfcc0cfd08>, <function OutputProducer.on_global_arguments at 0x7fbfcc09a488>, <function CLIQuery.on_global_arguments at 0x7fbfcc0bbea0>] Event: CommandInvoker.OnPreCommandTableCreate [] Installed command modules ['acr', 'acs', 'advisor', 'ams', 'appservice', 'backup', 'batch', 'batchai', 'billing', 'botservice', 'cdn', 'cloud', 'cognitiveservices', 'configure', 'consumption', 'container', 'cosmosdb', 'dla', 'dls', 'dms', 'eventgrid', 'eventhubs', 'extension', 'feedback', 'find', 'hdinsight', 'interactive', 'iot', 'iotcentral', 'keyvault', 'kusto', 'lab', 'maps', 'monitor', 'network', 'policyinsights', 'profile', 'rdbms', 'redis', 'relay', 'reservations', 'resource', 'role', 'search', 'security', 'servicebus', 'servicefabric', 'signalr', 'sql', 'sqlvm', 'storage', 'vm'] Loaded module 'acr' in 0.009 seconds. Loaded module 'acs' in 0.009 seconds. Loaded module 'advisor' in 0.002 seconds. Event: CommandLoader.OnLoadCommandTable [] Loaded module 'ams' in 0.039 seconds. Loaded module 'appservice' in 0.018 seconds. Loaded module 'backup' in 0.002 seconds. Event: CommandLoader.OnLoadCommandTable [] Loaded module 'batch' in 0.019 seconds. Loaded module 'batchai' in 0.009 seconds. Loaded module 'billing' in 0.001 seconds. Loaded module 'botservice' in 0.008 seconds. Event: CommandLoader.OnLoadCommandTable [] Loaded module 'cdn' in 0.002 seconds. Loaded module 'cloud' in 0.007 seconds. Loaded module 'cognitiveservices' in 0.001 seconds. Loaded module 'configure' in 0.001 seconds. Loaded module 'consumption' in 0.008 seconds. Loaded module 'container' in 0.001 seconds. Loaded module 'cosmosdb' in 0.009 seconds. Loaded module 'dla' in 0.010 seconds. Loaded module 'dls' in 0.002 seconds. Loaded module 'dms' in 0.008 seconds. Loaded module 'eventgrid' in 0.004 seconds. Loaded module 'eventhubs' in 0.006 seconds. Loaded module 'extension' in 0.001 seconds. Loaded module 'feedback' in 0.001 seconds. Loaded module 'find' in 0.007 seconds. Loaded module 'hdinsight' in 0.002 seconds. Loaded module 'interactive' in 0.000 seconds. Loaded module 'iot' in 0.009 seconds. Loaded module 'iotcentral' in 0.001 seconds. Loaded module 'keyvault' in 0.016 seconds. Loaded module 'kusto' in 0.001 seconds. Loaded module 'lab' in 0.009 seconds. Loaded module 'maps' in 0.001 seconds. Loaded module 'monitor' in 0.010 seconds. Loaded module 'network' in 0.060 seconds. Loaded module 'policyinsights' in 0.007 seconds. Loaded module 'profile' in 0.001 seconds. Loaded module 'rdbms' in 0.010 seconds. Loaded module 'redis' in 0.008 seconds. Loaded module 'relay' in 0.003 seconds. Loaded module 'reservations' in 0.007 seconds. Loaded module 'resource' in 0.012 seconds. Loaded module 'role' in 0.010 seconds. Loaded module 'search' in 0.007 seconds. Loaded module 'security' in 0.002 seconds. Loaded module 'servicebus' in 0.009 seconds. Loaded module 'servicefabric' in 0.001 seconds. Loaded module 'signalr' in 0.007 seconds. Loaded module 'sql' in 0.011 seconds. Loaded module 'sqlvm' in 0.002 seconds. Event: CommandLoader.OnLoadCommandTable [] Loaded module 'storage' in 0.063 seconds. Loaded module 'vm' in 0.036 seconds. Loaded all modules in 0.492 seconds. (note: there's always an overhead with the first module loaded) Extensions directory: '/root/.azure/cliextensions' Found 1 extensions: ['image-copy-extension'] Extensions directory: '/root/.azure/cliextensions' Loaded extension 'image-copy-extension' in 0.029 seconds. Event: CommandInvoker.OnPreCommandTableTruncate [] Event: CommandInvoker.OnPostCommandTableCreate [<function register_global_subscription_argument..add_subscription_parameter at 0x7fbfcbdd0048>, <function register_ids_argument..add_ids_arguments at 0x7fbfcbdfc9d8>] Event: CommandInvoker.OnCommandTableLoaded [] Event: CommandInvoker.OnPreParseArgs [<function _documentdb_deprecate at 0x7fbfc9a6aea0>] Event: CommandInvoker.OnPostParseArgs [<function OutputProducer.handle_output_argument at 0x7fbfcc09a510>, <function CLIQuery.handle_query_parameter at 0x7fbfcc0bbf28>, <function register_ids_argument..parse_ids_arguments at 0x7fbfcbdfca60>, <function handler at 0x7fbfc995a0d0>] Getting management service client client_type=ResourceManagementClient msrest.universal_http.requests : Configuring retry: max_retries=4, backoff_factor=0.8, max_backoff=90 attempting to read file /root/.azure/accessTokens.json as utf-8-sig adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - Authority:Performing instance discovery: ... adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - Authority:Performing static instance discovery adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - Authority:Authority validated via static instance discovery adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - TokenRequest:Getting token from cache with refresh if necessary. adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - CacheDriver:finding with query keys: {'_clientId': '...', 'userId': '...'} adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - CacheDriver:Looking for potential cache entries: {'_clientId': '...', 'userId': '...'} adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - CacheDriver:Found 2 potential entries. adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - CacheDriver:Resource specific token found. adal-python : dd449172-c4dd-49cf-9cd6-533cad751d27 - CacheDriver:Returning token from cache lookup, AccessTokenId: b'AOvvLNOQm5Z3dxxeLI05LMNWJMcck5qyqFe2KjezTYc=', RefreshTokenId: b'JRjQYudPmn6ko8c5io2FYiisJlnfVO2VLGsQTIn5Tq8=' msrest.http_logger : Request URL: 'https://management.chinacloudapi.cn/subscriptions//resourcegroups/?api-version=2018-05-01' msrest.http_logger : Request method: 'GET' msrest.http_logger : Request headers: msrest.http_logger : 'Accept': 'application/json' msrest.http_logger : 'accept-language': 'en-US' msrest.http_logger : 'User-Agent': 'python/3.6.5 (Linux-4.13.0-46-generic-x86_64-with-debian-stretch-sid) msrest/0.6.4 msrest_azure/0.6.0 resourcemanagementclient/2.1.0 Azure-SDK-For-Python AZURECLI/2.0.60' msrest.http_logger : Request body: msrest.http_logger : None 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.chinacloudapi.cn:443 urllib3.connectionpool : https://management.chinacloudapi.cn:443 "GET /subscriptions//resourcegroups/?api-version=2018-05-01 HTTP/1.1" 200 266 msrest.http_logger : Response status: 200 msrest.http_logger : Response headers: msrest.http_logger : 'Cache-Control': 'no-cache' msrest.http_logger : 'Pragma': 'no-cache' msrest.http_logger : 'Content-Type': 'application/json; charset=utf-8' msrest.http_logger : 'Content-Encoding': 'gzip' msrest.http_logger : 'Expires': '-1' msrest.http_logger : 'Vary': 'Accept-Encoding' msrest.http_logger : 'x-ms-ratelimit-remaining-subscription-reads': '14959' msrest.http_logger : 'x-ms-request-id': 'f10532b7-7ea2-4f58-b8e0-2e8435d748c4' msrest.http_logger : 'x-ms-correlation-request-id': 'f10532b7-7ea2-4f58-b8e0-2e8435d748c4' msrest.http_logger : 'x-ms-routing-request-id': 'CHINAEAST:20190429T081214Z:f10532b7-7ea2-4f58-b8e0-2e8435d748c4' msrest.http_logger : 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' msrest.http_logger : 'X-Content-Type-Options': 'nosniff' msrest.http_logger : 'Date': 'Mon, 29 Apr 2019 08:12:13 GMT' msrest.http_logger : 'Content-Length': '266' msrest.http_logger : Response content: msrest.http_logger : {"id":"/subscriptions//resourceGroups/","name":"","location":"chinanorth","properties":{"provisioningState":"Succeeded"}} Getting management service client client_type=ComputeManagementClient msrest.universal_http.requests : Configuring retry: max_retries=4, backoff_factor=0.8, max_backoff=90 adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - Authority:Performing instance discovery: ... adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - Authority:Performing static instance discovery adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - Authority:Authority validated via static instance discovery adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - TokenRequest:Getting token from cache with refresh if necessary. adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - CacheDriver:finding with query keys: {'_clientId': '...', 'userId': '...'} adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - CacheDriver:Looking for potential cache entries: {'_clientId': '...', 'userId': '...'} adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - CacheDriver:Found 2 potential entries. adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - CacheDriver:Resource specific token found. adal-python : a7075bbf-1f95-4e56-8112-63b73664d7db - CacheDriver:Returning token from cache lookup, AccessTokenId: b'AOvvLNOQm5Z3dxxeLI05LMNWJMcck5qyqFe2KjezTYc=', RefreshTokenId: b'JRjQYudPmn6ko8c5io2FYiisJlnfVO2VLGsQTIn5Tq8=' msrest.http_logger : Request URL: 'https://management.chinacloudapi.cn/subscriptions//resourceGroups//providers/Microsoft.Compute/snapshots/centos-image-20190429140209_os_disk_snapshot?api-version=2018-06-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': '352' msrest.http_logger : 'User-Agent': 'python/3.6.5 (Linux-4.13.0-46-generic-x86_64-with-debian-stretch-sid) msrest/0.6.4 msrest_azure/0.6.0 computemanagementclient/4.4.0 Azure-SDK-For-Python AZURECLI/2.0.60' msrest.http_logger : Request body: msrest.http_logger : {"location": "chinanorth", "tags": {"created_by": "image-copy-extension"}, "sku": {"name": "Standard_LRS"}, "properties": {"creationData": {"createOption": "Copy", "sourceResourceId": "/subscriptions//resourceGroups//providers/Microsoft.Compute/disks/centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693"}}} 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.chinacloudapi.cn:443 urllib3.connectionpool : https://management.chinacloudapi.cn:443 "PUT /subscriptions//resourceGroups//providers/Microsoft.Compute/snapshots/centos-image-20190429140209_os_disk_snapshot?api-version=2018-06-01 HTTP/1.1" 404 138 msrest.http_logger : Response status: 404 msrest.http_logger : Response headers: msrest.http_logger : 'Cache-Control': 'no-cache' msrest.http_logger : 'Pragma': 'no-cache' msrest.http_logger : 'Content-Length': '138' msrest.http_logger : 'Content-Type': 'application/json; charset=utf-8' msrest.http_logger : 'Expires': '-1' msrest.http_logger : 'x-ms-ratelimit-remaining-resource': 'Microsoft.Compute/HighCostSnapshotCreateHydrate3Min;238,Microsoft.Compute/HighCostSnapshotCreateHydrate30Min;1913' msrest.http_logger : 'Strict-Transport-Security': 'max-age=31536000; includeSubDomains' msrest.http_logger : 'x-ms-served-by': '9390cbf5-31a7-4d62-b184-20d89fb8566c_131758399861263428' msrest.http_logger : 'x-ms-request-id': '78179d6c-5a72-43ab-9311-da2d14504859' msrest.http_logger : 'Server': 'Microsoft-HTTPAPI/2.0, Microsoft-HTTPAPI/2.0' msrest.http_logger : 'x-ms-ratelimit-remaining-subscription-writes': '1199' msrest.http_logger : 'x-ms-correlation-request-id': 'e6c4385e-d870-4c5f-b549-12160a7f0b13' msrest.http_logger : 'x-ms-routing-request-id': 'CHINAEAST:20190429T081215Z:e6c4385e-d870-4c5f-b549-12160a7f0b13' msrest.http_logger : 'X-Content-Type-Options': 'nosniff' msrest.http_logger : 'Date': 'Mon, 29 Apr 2019 08:12:14 GMT' msrest.http_logger : Response content: msrest.http_logger : { "error": { "code": "NotFound", "message": "Resource centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693 is not found." } } msrest.exceptions : Resource centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693 is not found. Resource centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693 is not found. telemetry.save : Save telemetry record of length 2526 in cache telemetry.check : Negative: The /root/.azure/telemetry.txt was modified at 2019-04-29 08:11:56.209563, which in less than 600.000000 s

However, we can create snapshot via portal with api-version=2015-11-01

image

Can someone look into it? Thanks a lot!

StellaZhou64 commented 5 years ago

root@Ubuntu1710:~# az --version azure-cli 2.0.60 *

acr 2.2.2 acs 2.3.19 advisor 2.0.0 ams 0.4.2 appservice 0.2.15 backup 1.2.1 batch 4.0.0 batchai 0.4.7 billing 0.2.0 botservice 0.1.8 cdn 0.2.0 cloud 2.1.0 cognitiveservices 0.2.4 command-modules-nspkg 2.0.2 configure 2.0.20 consumption 0.4.2 container 0.3.15 core 2.0.60 cosmosdb 0.2.8 dla 0.2.4 dls 0.1.8 dms 0.1.2 eventgrid 0.2.1 eventhubs 0.3.4 extension 0.2.3 feedback 2.1.4 find 0.3.0 hdinsight 0.3.2 interactive 0.4.1 iot 0.3.6 iotcentral 0.1.6 keyvault 2.2.12 kusto 0.2.0 lab 0.1.5 maps 0.3.3 monitor 0.2.10 network 2.3.4 nspkg 3.0.3 policyinsights 0.1.1 profile 2.1.3 rdbms 0.3.8 redis 0.4.1 relay 0.1.3 reservations 0.4.1 resource 2.1.11 role 2.4.2 search 0.1.1 security 0.1.0 servicebus 0.3.3 servicefabric 0.1.14 signalr 1.0.0 sql 2.1.9 sqlvm 0.1.0 storage 2.3.1 telemetry 1.0.1 vm 2.2.16 *

Extensions: image-copy-extension 0.0.9

Python location '/opt/az/bin/python3' Extensions directory '/root/.azure/cliextensions'

Python (Linux) 3.6.5 (default, Mar 7 2019, 19:44:42) [GCC 7.2.0]

Legal docs and information: aka.ms/AzureCliLegal

You have 48 updates available. Consider updating your CLI installation.

adewaleo commented 5 years ago

@StellaZhou64, What is the source: centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693? Is it a managed disk? If so what does az disk show return?

If the disk is not in the same resource group as that being used for az snapshot create, then you need to specify the full resource id of the disk in snapshot create.

StellaZhou64 commented 5 years ago

Thanks Adewaleo. I just found the issue is that my source managed disk is not in the same region as its resource group. The managed disk is in chinanorth2, but its resource group is in chinanorth. From the log, it seems try to find the disk in china north.

msrest.http_logger : {"location": "chinanorth", "tags": {"created_by": "image-copy-extension"}, "sku": {"name": "Standard_LRS"}, "properties": {"creationData": {"createOption": "Copy", "sourceResourceId": "/subscriptions//resourceGroups//providers/Microsoft.Compute/disks/centos_OsDisk_1_73147bcf4a4d431c8535d7c4ceb61693"}}}

Then I tried to take a snapshot for a managed disk which is in the same region as its resource group and it succeeded.