diff --git a/src/azure-cli/azure/cli/command_modules/vm/custom.py b/src/azure-cli/azure/cli/command_modules/vm/custom.py index a327be38145..9f8b1145811 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/custom.py +++ b/src/azure-cli/azure/cli/command_modules/vm/custom.py @@ -2784,9 +2784,9 @@ def list_vmss_instance_public_ips(cmd, resource_group_name, vm_scale_set_name): def reimage_vmss(cmd, resource_group_name, vm_scale_set_name, instance_id=None, no_wait=False): client = _compute_client_factory(cmd.cli_ctx) if instance_id: - return sdk_no_wait(no_wait, client.virtual_machine_scale_set_vms.reimage, + return sdk_no_wait(no_wait, client.virtual_machine_scale_set_vms.begin_reimage, resource_group_name, vm_scale_set_name, instance_id) - return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.reimage, resource_group_name, vm_scale_set_name) + return sdk_no_wait(no_wait, client.virtual_machine_scale_sets.begin_reimage, resource_group_name, vm_scale_set_name) def restart_vmss(cmd, resource_group_name, vm_scale_set_name, instance_ids=None, no_wait=False): diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_reimage.yaml b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_reimage.yaml new file mode 100644 index 00000000000..727e43a487f --- /dev/null +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/recordings/test_vmss_reimage.yaml @@ -0,0 +1,989 @@ +interactions: +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image + User-Agent: + - python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3 + azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1 + accept-language: + - en-US + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001?api-version=2020-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001","name":"cli_test_vmss_reimage_000001","type":"Microsoft.Resources/resourceGroups","location":"westus","tags":{"product":"azurecli","cause":"automation","date":"2021-01-11T06:17:58Z"},"properties":{"provisioningState":"Succeeded"}}' + headers: + cache-control: + - no-cache + content-length: + - '428' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:18:02 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.22.0 + method: GET + uri: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/arm-compute/quickstart-templates/aliases.json + response: + body: + string: "{\n \"$schema\": \"http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json\",\n + \ \"contentVersion\": \"1.0.0.0\",\n \"parameters\": {},\n \"variables\": + {},\n \"resources\": [],\n \"outputs\": {\n \"aliases\": {\n \"type\": + \"object\",\n \"value\": {\n \"Linux\": {\n \"CentOS\": + {\n \"publisher\": \"OpenLogic\",\n \"offer\": \"CentOS\",\n + \ \"sku\": \"7.5\",\n \"version\": \"latest\"\n },\n + \ \"CoreOS\": {\n \"publisher\": \"CoreOS\",\n \"offer\": + \"CoreOS\",\n \"sku\": \"Stable\",\n \"version\": \"latest\"\n + \ },\n \"Debian\": {\n \"publisher\": \"Debian\",\n + \ \"offer\": \"debian-10\",\n \"sku\": \"10\",\n \"version\": + \"latest\"\n },\n \"openSUSE-Leap\": {\n \"publisher\": + \"SUSE\",\n \"offer\": \"openSUSE-Leap\",\n \"sku\": + \"42.3\",\n \"version\": \"latest\"\n },\n \"RHEL\": + {\n \"publisher\": \"RedHat\",\n \"offer\": \"RHEL\",\n + \ \"sku\": \"7-LVM\",\n \"version\": \"latest\"\n },\n + \ \"SLES\": {\n \"publisher\": \"SUSE\",\n \"offer\": + \"SLES\",\n \"sku\": \"15\",\n \"version\": \"latest\"\n + \ },\n \"UbuntuLTS\": {\n \"publisher\": \"Canonical\",\n + \ \"offer\": \"UbuntuServer\",\n \"sku\": \"18.04-LTS\",\n + \ \"version\": \"latest\"\n }\n },\n \"Windows\": + {\n \"Win2019Datacenter\": {\n \"publisher\": \"MicrosoftWindowsServer\",\n + \ \"offer\": \"WindowsServer\",\n \"sku\": \"2019-Datacenter\",\n + \ \"version\": \"latest\"\n },\n \"Win2016Datacenter\": + {\n \"publisher\": \"MicrosoftWindowsServer\",\n \"offer\": + \"WindowsServer\",\n \"sku\": \"2016-Datacenter\",\n \"version\": + \"latest\"\n },\n \"Win2012R2Datacenter\": {\n \"publisher\": + \"MicrosoftWindowsServer\",\n \"offer\": \"WindowsServer\",\n \"sku\": + \"2012-R2-Datacenter\",\n \"version\": \"latest\"\n },\n + \ \"Win2012Datacenter\": {\n \"publisher\": \"MicrosoftWindowsServer\",\n + \ \"offer\": \"WindowsServer\",\n \"sku\": \"2012-Datacenter\",\n + \ \"version\": \"latest\"\n },\n \"Win2008R2SP1\": + {\n \"publisher\": \"MicrosoftWindowsServer\",\n \"offer\": + \"WindowsServer\",\n \"sku\": \"2008-R2-SP1\",\n \"version\": + \"latest\"\n }\n }\n }\n }\n }\n}\n" + headers: + accept-ranges: + - bytes + access-control-allow-origin: + - '*' + cache-control: + - max-age=300 + connection: + - keep-alive + content-length: + - '2501' + content-security-policy: + - default-src 'none'; style-src 'unsafe-inline'; sandbox + content-type: + - text/plain; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:18:03 GMT + etag: + - W/"540044b4084c3c314537f1baa1770f248628b2bc9ba0328f1004c33862e049da" + expires: + - Mon, 11 Jan 2021 06:23:03 GMT + source-age: + - '127' + strict-transport-security: + - max-age=31536000 + vary: + - Authorization,Accept-Encoding, Accept-Encoding + via: + - 1.1 varnish (Varnish/6.0), 1.1 varnish + x-cache: + - HIT, HIT + x-cache-hits: + - 1, 1 + x-content-type-options: + - nosniff + x-fastly-request-id: + - 1c3e89659c23158e665f530a40cfc9ecdde11b80 + x-frame-options: + - deny + x-github-request-id: + - A7D4:3C5A:2710B6:291851:5FFBE5DC + x-served-by: + - cache-sin18044-SIN + x-timer: + - S1610345883.057376,VS0,VE254 + x-xss-protection: + - 1; mode=block + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json, text/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-network/17.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks?api-version=2018-01-01 + response: + body: + string: '{"value":[]}' + headers: + cache-control: + - no-cache + content-length: + - '12' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:18:03 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: '{"properties": {"template": {"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", "parameters": {}, "variables": {}, "resources": + [{"name": "vmss1VNET", "type": "Microsoft.Network/virtualNetworks", "location": + "westus", "apiVersion": "2015-06-15", "dependsOn": [], "tags": {}, "properties": + {"addressSpace": {"addressPrefixes": ["10.0.0.0/16"]}, "subnets": [{"name": + "vmss1Subnet", "properties": {"addressPrefix": "10.0.0.0/24"}}]}}, {"apiVersion": + "2018-01-01", "type": "Microsoft.Network/publicIPAddresses", "name": "vmss1LBPublicIP", + "location": "westus", "tags": {}, "dependsOn": [], "properties": {"publicIPAllocationMethod": + "Dynamic"}}, {"type": "Microsoft.Network/loadBalancers", "name": "vmss1LB", + "location": "westus", "tags": {}, "apiVersion": "2018-01-01", "dependsOn": ["Microsoft.Network/virtualNetworks/vmss1VNET", + "Microsoft.Network/publicIpAddresses/vmss1LBPublicIP"], "properties": {"backendAddressPools": + [{"name": "vmss1LBBEPool"}], "inboundNatPools": [{"name": "vmss1LBNatPool", + "properties": {"frontendIPConfiguration": {"id": "[concat(resourceId(''Microsoft.Network/loadBalancers'', + ''vmss1LB''), ''/frontendIPConfigurations/'', ''loadBalancerFrontEnd'')]"}, + "protocol": "tcp", "frontendPortRangeStart": "50000", "frontendPortRangeEnd": + "50119", "backendPort": 22}}], "frontendIPConfigurations": [{"name": "loadBalancerFrontEnd", + "properties": {"publicIPAddress": {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/publicIPAddresses/vmss1LBPublicIP"}}}]}}, + {"type": "Microsoft.Compute/virtualMachineScaleSets", "name": "vmss1", "location": + "westus", "tags": {}, "apiVersion": "2020-06-01", "dependsOn": ["Microsoft.Network/virtualNetworks/vmss1VNET", + "Microsoft.Network/loadBalancers/vmss1LB"], "sku": {"name": "Standard_DS1_v2", + "capacity": 2}, "properties": {"overprovision": true, "upgradePolicy": {"mode": + "manual"}, "virtualMachineProfile": {"storageProfile": {"osDisk": {"createOption": + "FromImage", "caching": "ReadWrite", "managedDisk": {"storageAccountType": null}}, + "imageReference": {"publisher": "OpenLogic", "offer": "CentOS", "sku": "7.5", + "version": "latest"}}, "networkProfile": {"networkInterfaceConfigurations": + [{"name": "vmss166b2Nic", "properties": {"primary": "true", "ipConfigurations": + [{"name": "vmss166b2IPConfig", "properties": {"subnet": {"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks/vmss1VNET/subnets/vmss1Subnet"}, + "loadBalancerBackendAddressPools": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB/backendAddressPools/vmss1LBBEPool"}], + "loadBalancerInboundNatPools": [{"id": "/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB/inboundNatPools/vmss1LBNatPool"}]}}]}}]}, + "osProfile": {"computerNamePrefix": "vmss166b2", "adminUsername": "fey", "linuxConfiguration": + {"disablePasswordAuthentication": true, "ssh": {"publicKeys": [{"path": "/home/fey/.ssh/authorized_keys", + "keyData": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDmzXeK++L20uMK/Ug5wpjnWWyMlHoecEOxyHueHc1gPDj8qgLChiHt1OWJ1sDjiqBJ+hEEwZLjN8lCmUvWzzrl20d7M/BVp1ejulE/zr999kWuY3m5+FpAkbbxeO9LWoafwOir9dPzIOjDGdPWKbgHr3SerOHAuvVdXJDhWHtW5lB/MEnrxi48Pz/8k1lD1YccUAI6zDgKVJPBEk9fWMW8H0hKYsRXmlxdtg2npBQK7kbmcB2NJPEhTVgxVPqSaBVAt2lOCC/QQvAXcoD0lJGujp1IVYqSUarS5RnrYEDZ9Q6EKduWrP0GFkFkF8YzpFe+BRFaV8bLJrvZN43vgzRj + fey@DESKTOP-ARGPJS4\n"}]}}}}, "singlePlacementGroup": null}}], "outputs": {"VMSS": + {"type": "object", "value": "[reference(resourceId(''Microsoft.Compute/virtualMachineScaleSets'', + ''vmss1''),providers(''Microsoft.Compute'', ''virtualMachineScaleSets'').apiVersions[0])]"}}}, + "parameters": {}, "mode": "Incremental"}}' + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + Content-Length: + - '4160' + Content-Type: + - application/json; charset=utf-8 + ParameterSetName: + - -g -n --image + User-Agent: + - python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3 + azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1 + accept-language: + - en-US + method: PUT + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2020-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/vmss_deploy_KBaBpN6z48zrTVeXVPyDYcpb7NHlSRQu","name":"vmss_deploy_KBaBpN6z48zrTVeXVPyDYcpb7NHlSRQu","type":"Microsoft.Resources/deployments","properties":{"templateHash":"7943905744907000577","parameters":{},"mode":"Incremental","provisioningState":"Accepted","timestamp":"2021-01-11T06:18:07.9069898Z","duration":"PT2.470708S","correlationId":"931beb14-ce20-4b99-bf19-a21cc465f1ea","providers":[{"namespace":"Microsoft.Network","resourceTypes":[{"resourceType":"virtualNetworks","locations":["westus"]},{"resourceType":"publicIPAddresses","locations":["westus"]},{"resourceType":"loadBalancers","locations":["westus"]}]},{"namespace":"Microsoft.Compute","resourceTypes":[{"resourceType":"virtualMachineScaleSets","locations":["westus"]}]}],"dependencies":[{"dependsOn":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks/vmss1VNET","resourceType":"Microsoft.Network/virtualNetworks","resourceName":"vmss1VNET"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/publicIPAddresses/vmss1LBPublicIP","resourceType":"Microsoft.Network/publicIPAddresses","resourceName":"vmss1LBPublicIP"}],"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB","resourceType":"Microsoft.Network/loadBalancers","resourceName":"vmss1LB"},{"dependsOn":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks/vmss1VNET","resourceType":"Microsoft.Network/virtualNetworks","resourceName":"vmss1VNET"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB","resourceType":"Microsoft.Network/loadBalancers","resourceName":"vmss1LB"}],"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1","resourceType":"Microsoft.Compute/virtualMachineScaleSets","resourceName":"vmss1"}]}}' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/vmss_deploy_KBaBpN6z48zrTVeXVPyDYcpb7NHlSRQu/operationStatuses/08585912610000413475?api-version=2020-10-01 + cache-control: + - no-cache + content-length: + - '2691' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:18:10 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-subscription-writes: + - '1198' + status: + code: 201 + message: Created +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image + User-Agent: + - python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3 + azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585912610000413475?api-version=2020-10-01 + response: + body: + string: '{"status":"Running"}' + headers: + cache-control: + - no-cache + content-length: + - '20' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:18:41 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image + User-Agent: + - python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3 + azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585912610000413475?api-version=2020-10-01 + response: + body: + string: '{"status":"Running"}' + headers: + cache-control: + - no-cache + content-length: + - '20' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:19:11 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image + User-Agent: + - python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3 + azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585912610000413475?api-version=2020-10-01 + response: + body: + string: '{"status":"Running"}' + headers: + cache-control: + - no-cache + content-length: + - '20' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:19:43 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image + User-Agent: + - python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3 + azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/mock-deployment/operationStatuses/08585912610000413475?api-version=2020-10-01 + response: + body: + string: '{"status":"Succeeded"}' + headers: + cache-control: + - no-cache + content-length: + - '22' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:20:13 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - application/json + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss create + Connection: + - keep-alive + ParameterSetName: + - -g -n --image + User-Agent: + - python/3.7.4 (Windows-10-10.0.19041-SP0) msrest/0.6.18 msrest_azure/0.6.3 + azure-mgmt-resource/12.0.0 Azure-SDK-For-Python AZURECLI/2.17.1 + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/mock-deployment?api-version=2020-10-01 + response: + body: + string: '{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Resources/deployments/vmss_deploy_KBaBpN6z48zrTVeXVPyDYcpb7NHlSRQu","name":"vmss_deploy_KBaBpN6z48zrTVeXVPyDYcpb7NHlSRQu","type":"Microsoft.Resources/deployments","properties":{"templateHash":"7943905744907000577","parameters":{},"mode":"Incremental","provisioningState":"Succeeded","timestamp":"2021-01-11T06:20:00.2798114Z","duration":"PT1M54.8435296S","correlationId":"931beb14-ce20-4b99-bf19-a21cc465f1ea","providers":[{"namespace":"Microsoft.Network","resourceTypes":[{"resourceType":"virtualNetworks","locations":["westus"]},{"resourceType":"publicIPAddresses","locations":["westus"]},{"resourceType":"loadBalancers","locations":["westus"]}]},{"namespace":"Microsoft.Compute","resourceTypes":[{"resourceType":"virtualMachineScaleSets","locations":["westus"]}]}],"dependencies":[{"dependsOn":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks/vmss1VNET","resourceType":"Microsoft.Network/virtualNetworks","resourceName":"vmss1VNET"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/publicIPAddresses/vmss1LBPublicIP","resourceType":"Microsoft.Network/publicIPAddresses","resourceName":"vmss1LBPublicIP"}],"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB","resourceType":"Microsoft.Network/loadBalancers","resourceName":"vmss1LB"},{"dependsOn":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks/vmss1VNET","resourceType":"Microsoft.Network/virtualNetworks","resourceName":"vmss1VNET"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB","resourceType":"Microsoft.Network/loadBalancers","resourceName":"vmss1LB"}],"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1","resourceType":"Microsoft.Compute/virtualMachineScaleSets","resourceName":"vmss1"}],"outputs":{"vmss":{"type":"Object","value":{"singlePlacementGroup":true,"upgradePolicy":{"mode":"Manual"},"virtualMachineProfile":{"osProfile":{"computerNamePrefix":"vmss166b2","adminUsername":"fey","linuxConfiguration":{"disablePasswordAuthentication":true,"ssh":{"publicKeys":[{"path":"/home/fey/.ssh/authorized_keys","keyData":"ssh-rsa + AAAAB3NzaC1yc2EAAAADAQABAAABAQDmzXeK++L20uMK/Ug5wpjnWWyMlHoecEOxyHueHc1gPDj8qgLChiHt1OWJ1sDjiqBJ+hEEwZLjN8lCmUvWzzrl20d7M/BVp1ejulE/zr999kWuY3m5+FpAkbbxeO9LWoafwOir9dPzIOjDGdPWKbgHr3SerOHAuvVdXJDhWHtW5lB/MEnrxi48Pz/8k1lD1YccUAI6zDgKVJPBEk9fWMW8H0hKYsRXmlxdtg2npBQK7kbmcB2NJPEhTVgxVPqSaBVAt2lOCC/QQvAXcoD0lJGujp1IVYqSUarS5RnrYEDZ9Q6EKduWrP0GFkFkF8YzpFe+BRFaV8bLJrvZN43vgzRj + fey@DESKTOP-ARGPJS4\n"}]},"provisionVMAgent":true},"secrets":[],"allowExtensionOperations":true,"requireGuestProvisionSignal":true},"storageProfile":{"osDisk":{"createOption":"FromImage","caching":"ReadWrite","managedDisk":{"storageAccountType":"Premium_LRS"},"diskSizeGB":30},"imageReference":{"publisher":"OpenLogic","offer":"CentOS","sku":"7.5","version":"latest"}},"networkProfile":{"networkInterfaceConfigurations":[{"name":"vmss166b2Nic","properties":{"primary":true,"enableAcceleratedNetworking":false,"dnsSettings":{"dnsServers":[]},"enableIPForwarding":false,"ipConfigurations":[{"name":"vmss166b2IPConfig","properties":{"subnet":{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks/vmss1VNET/subnets/vmss1Subnet"},"privateIPAddressVersion":"IPv4","loadBalancerBackendAddressPools":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB/backendAddressPools/vmss1LBBEPool"}],"loadBalancerInboundNatPools":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB/inboundNatPools/vmss1LBNatPool"}]}}]}}]}},"provisioningState":"Succeeded","overprovision":true,"doNotRunExtensionsOnOverprovisionedVMs":false,"uniqueId":"f34c4cae-fe31-4938-9345-f9cc1e2c5496"}}},"outputResources":[{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/loadBalancers/vmss1LB"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/publicIPAddresses/vmss1LBPublicIP"},{"id":"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Network/virtualNetworks/vmss1VNET"}]}}' + headers: + cache-control: + - no-cache + content-length: + - '5856' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:20:14 GMT + expires: + - '-1' + pragma: + - no-cache + strict-transport-security: + - max-age=31536000; includeSubDomains + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + ParameterSetName: + - -g -n --instance-id + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1/virtualmachines/1/reimage?api-version=2020-06-01 + response: + body: + string: '' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/5f7c3225-fd04-4415-8c0d-c5efdfad0755?api-version=2020-06-01 + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 11 Jan 2021 06:20:15 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/5f7c3225-fd04-4415-8c0d-c5efdfad0755?monitor=true&api-version=2020-06-01 + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/VMScaleSetActions3Min;239,Microsoft.Compute/VMScaleSetActions30Min;1199,Microsoft.Compute/VMScaleSetVMActions3Min;199,Microsoft.Compute/VMScaleSetVMActions30Min;999,Microsoft.Compute/VMScaleSetBatchedVMRequests5Min;1195,Microsoft.Compute/VmssQueuedVMOperations;4799 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-ms-request-charge: + - '1' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n --instance-id + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/5f7c3225-fd04-4415-8c0d-c5efdfad0755?api-version=2020-06-01 + response: + body: + string: "{\r\n \"startTime\": \"2021-01-11T06:20:16.1505052+00:00\",\r\n \"status\": + \"InProgress\",\r\n \"name\": \"5f7c3225-fd04-4415-8c0d-c5efdfad0755\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '134' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:20:45 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14996,Microsoft.Compute/GetOperation30Min;29991 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n --instance-id + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/5f7c3225-fd04-4415-8c0d-c5efdfad0755?api-version=2020-06-01 + response: + body: + string: "{\r\n \"startTime\": \"2021-01-11T06:20:16.1505052+00:00\",\r\n \"status\": + \"InProgress\",\r\n \"name\": \"5f7c3225-fd04-4415-8c0d-c5efdfad0755\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '134' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:21:16 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14993,Microsoft.Compute/GetOperation30Min;29988 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n --instance-id + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/5f7c3225-fd04-4415-8c0d-c5efdfad0755?api-version=2020-06-01 + response: + body: + string: "{\r\n \"startTime\": \"2021-01-11T06:20:16.1505052+00:00\",\r\n \"endTime\": + \"2021-01-11T06:21:29.1348458+00:00\",\r\n \"status\": \"Succeeded\",\r\n + \ \"name\": \"5f7c3225-fd04-4415-8c0d-c5efdfad0755\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '184' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:21:47 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14990,Microsoft.Compute/GetOperation30Min;29985 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n --instance-id + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/5f7c3225-fd04-4415-8c0d-c5efdfad0755?monitor=true&api-version=2020-06-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 11 Jan 2021 06:21:47 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14989,Microsoft.Compute/GetOperation30Min;29984 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + Content-Length: + - '0' + Content-Type: + - application/json + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: POST + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/cli_test_vmss_reimage_000001/providers/Microsoft.Compute/virtualMachineScaleSets/vmss1/reimage?api-version=2020-06-01 + response: + body: + string: '' + headers: + azure-asyncoperation: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/d4cd69b8-db86-48f1-966e-f82b799edeba?api-version=2020-06-01 + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 11 Jan 2021 06:21:48 GMT + expires: + - '-1' + location: + - https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/d4cd69b8-db86-48f1-966e-f82b799edeba?monitor=true&api-version=2020-06-01 + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/VMScaleSetActions3Min;238,Microsoft.Compute/VMScaleSetActions30Min;1198,Microsoft.Compute/VMScaleSetBatchedVMRequests5Min;1193,Microsoft.Compute/VmssQueuedVMOperations;4798 + x-ms-ratelimit-remaining-subscription-writes: + - '1199' + x-ms-request-charge: + - '2' + status: + code: 202 + message: Accepted +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/d4cd69b8-db86-48f1-966e-f82b799edeba?api-version=2020-06-01 + response: + body: + string: "{\r\n \"startTime\": \"2021-01-11T06:21:48.7598135+00:00\",\r\n \"status\": + \"InProgress\",\r\n \"name\": \"d4cd69b8-db86-48f1-966e-f82b799edeba\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '134' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:22:18 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14987,Microsoft.Compute/GetOperation30Min;29982 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/d4cd69b8-db86-48f1-966e-f82b799edeba?api-version=2020-06-01 + response: + body: + string: "{\r\n \"startTime\": \"2021-01-11T06:21:48.7598135+00:00\",\r\n \"status\": + \"InProgress\",\r\n \"name\": \"d4cd69b8-db86-48f1-966e-f82b799edeba\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '134' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:22:48 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14985,Microsoft.Compute/GetOperation30Min;29979 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/d4cd69b8-db86-48f1-966e-f82b799edeba?api-version=2020-06-01 + response: + body: + string: "{\r\n \"startTime\": \"2021-01-11T06:21:48.7598135+00:00\",\r\n \"endTime\": + \"2021-01-11T06:23:11.494231+00:00\",\r\n \"status\": \"Succeeded\",\r\n + \ \"name\": \"d4cd69b8-db86-48f1-966e-f82b799edeba\"\r\n}" + headers: + cache-control: + - no-cache + content-length: + - '183' + content-type: + - application/json; charset=utf-8 + date: + - Mon, 11 Jan 2021 06:23:18 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + transfer-encoding: + - chunked + vary: + - Accept-Encoding + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14983,Microsoft.Compute/GetOperation30Min;29976 + status: + code: 200 + message: OK +- request: + body: null + headers: + Accept: + - '*/*' + Accept-Encoding: + - gzip, deflate + CommandName: + - vmss reimage + Connection: + - keep-alive + ParameterSetName: + - -g -n + User-Agent: + - AZURECLI/2.17.1 azsdk-python-azure-mgmt-compute/18.0.0 Python/3.7.4 (Windows-10-10.0.19041-SP0) + method: GET + uri: https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Compute/locations/westus/operations/d4cd69b8-db86-48f1-966e-f82b799edeba?monitor=true&api-version=2020-06-01 + response: + body: + string: '' + headers: + cache-control: + - no-cache + content-length: + - '0' + date: + - Mon, 11 Jan 2021 06:23:19 GMT + expires: + - '-1' + pragma: + - no-cache + server: + - Microsoft-HTTPAPI/2.0 + - Microsoft-HTTPAPI/2.0 + strict-transport-security: + - max-age=31536000; includeSubDomains + x-content-type-options: + - nosniff + x-ms-ratelimit-remaining-resource: + - Microsoft.Compute/GetOperation3Min;14982,Microsoft.Compute/GetOperation30Min;29975 + status: + code: 200 + message: OK +version: 1 diff --git a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py index 08ccec91eb0..bd2606d47a5 100644 --- a/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py +++ b/src/azure-cli/azure/cli/command_modules/vm/tests/latest/test_vm_commands.py @@ -5002,5 +5002,14 @@ def test_vm_disk_logical_sector_size(self, resource_group): ]) +class VMSSReimageScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='cli_test_vmss_reimage_') + def test_vmss_reimage(self, resource_group): + self.cmd('vmss create -g {rg} -n vmss1 --image centos') + self.cmd('vmss reimage -g {rg} -n vmss1 --instance-id 1') + self.cmd('vmss reimage -g {rg} -n vmss1') + + if __name__ == '__main__': unittest.main()