Adds methods listAll and listByLocation to VirtualMachineAPI (#21)

* Adds methods listAll and listByLocation to VirtualMachineAPI

Adds Mock tests fixes

* Minor comments

* Overrides test to avoid case sensitive comparation

* Adds comment to justify overriding base test method

* Enables list by location to improve performance in listNodes abstraction

* Returns all available VMs if no regions are specified
This commit is contained in:
Daniel Estévez 2019-05-17 03:41:38 -04:00 committed by Ignasi Barrera
parent e1c64244cb
commit f2e955dadf
9 changed files with 887 additions and 32 deletions

View File

@ -132,7 +132,7 @@ public interface AzureComputeApi extends Closeable {
* @see <a href="https://msdn.microsoft.com/en-us/library/azure/mt163630.aspx">docs</a>
*/
@Delegate
VirtualMachineApi getVirtualMachineApi(@PathParam("resourceGroup") String resourceGroup);
VirtualMachineApi getVirtualMachineApi(@Nullable @PathParam("resourceGroup") String resourceGroup);
/**
* The Virtual Machine Scale Set API includes operations for managing the virtual machines in your subscription.

View File

@ -351,14 +351,12 @@ public class AzureComputeServiceAdapter implements ComputeServiceAdapter<Virtual
@Override
public Iterable<VirtualMachine> listNodes() {
ImmutableList.Builder<VirtualMachine> nodes = builder();
for (ResourceGroup resourceGroup : api.getResourceGroupApi().list()) {
List<VirtualMachine> vms = api.getVirtualMachineApi(resourceGroup.name()).list();
nodes.addAll(filter(vms, new Predicate<VirtualMachine>() {
@Override
public boolean apply(VirtualMachine input) {
return regionIds.get().isEmpty() || regionIds.get().contains(input.location());
}
}));
if (regionIds.get().isEmpty()) {
nodes.addAll(api.getVirtualMachineApi(null).listAll());
} else {
for (final String location : regionIds.get()) {
nodes.addAll(api.getVirtualMachineApi(null).listByLocation(location));
}
}
return nodes.build();
}

View File

@ -55,14 +55,13 @@ import org.jclouds.rest.binders.BindToJsonPayload;
*
* @see <a href="https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines">docs</a>
*/
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines")
@RequestFilters({ OAuthFilter.class, ApiVersionFilter.class })
@Consumes(MediaType.APPLICATION_JSON)
public interface VirtualMachineApi {
@Named("GetVirtualMachine")
@GET
@Path("/{name}")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
VirtualMachine get(@PathParam("name") String name);
@ -71,64 +70,77 @@ public interface VirtualMachineApi {
*/
@Named("GetVirtualMachineInstance")
@GET
@Path("/{name}/instanceView")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/instanceView")
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
VirtualMachineInstance getInstanceDetails(@PathParam("name") String name);
@Named("CreateOrUpdateVirtualMachine")
@PUT
@MapBinder(BindToJsonPayload.class)
@Path("/{vmname}")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{vmname}")
@QueryParams(keys = "validating", values = "false")
VirtualMachine createOrUpdate(@PathParam("vmname") String vmname,
@PayloadParam("location") String location,
@PayloadParam("properties") VirtualMachineProperties properties,
@PayloadParam("tags") Map<String, String> tags,
@Nullable @PayloadParam("plan") Plan plan);
VirtualMachine createOrUpdate(@PathParam("vmname") String vmname, @PayloadParam("location") String location,
@PayloadParam("properties") VirtualMachineProperties properties,
@PayloadParam("tags") Map<String, String> tags, @Nullable @PayloadParam("plan") Plan plan);
@Named("ListVirtualMachines")
@GET
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines")
@SelectJson("value")
@Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
List<VirtualMachine> list();
@Named("ListVirtualMachinesAll")
@GET
@Path("/providers/Microsoft.Compute/virtualMachines")
@SelectJson("value")
@Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
List<VirtualMachine> listAll();
@Named("ListVirtualMachinesByLocation")
@GET
@Path("/providers/Microsoft.Compute/locations/{location}/virtualMachines")
@SelectJson("value")
@Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
List<VirtualMachine> listByLocation(@PathParam("location") String location);
@Named("ListAvailableSizes")
@GET
@SelectJson("value")
@Path("/{name}/vmSizes")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/vmSizes")
@Fallback(Fallbacks.EmptyListOnNotFoundOr404.class)
List<VMSize> listAvailableSizes(@PathParam("name") String name);
@Named("DeleteVirtualMachine")
@DELETE
@Path("/{name}")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}")
@ResponseParser(URIParser.class)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
URI delete(@PathParam("name") String name);
@Named("RestartVirtualMachine")
@POST
@Path("/{name}/restart")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/restart")
void restart(@PathParam("name") String name);
@Named("StartVirtualMachine")
@POST
@Path("/{name}/start")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/start")
void start(@PathParam("name") String name);
@Named("StopVirtualMachine")
@POST
@Path("/{name}/powerOff")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/powerOff")
void stop(@PathParam("name") String name);
@Named("DeallocateVirtualMachine")
@POST
@Path("/{name}/deallocate")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/deallocate")
void deallocate(@PathParam("name") String name);
@Named("generalize")
@POST
@Path("/{name}/generalize")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/generalize")
void generalize(@PathParam("name") String name);
/**
@ -140,13 +152,12 @@ public interface VirtualMachineApi {
@Named("capture")
@POST
@Payload("%7B\"vhdPrefix\":\"{vhdPrefix}\",\"destinationContainerName\":\"{destinationContainerName}\",\"overwriteVhds\":\"true\"%7D")
@Path("/{name}/capture")
@Path("/resourceGroups/{resourceGroup}/providers/Microsoft.Compute/virtualMachines/{name}/capture")
@ResponseParser(URIParser.class)
@Fallback(Fallbacks.NullOnNotFoundOr404.class)
@Produces(MediaType.APPLICATION_JSON)
URI capture(@PathParam("name") String name,
@PayloadParam("vhdPrefix") String vhdPrefix,
@PayloadParam("destinationContainerName") String destinationContainerName);
URI capture(@PathParam("name") String name, @PayloadParam("vhdPrefix") String vhdPrefix,
@PayloadParam("destinationContainerName") String destinationContainerName);
}

View File

@ -16,16 +16,23 @@
*/
package org.jclouds.azurecompute.arm.compute;
import static com.google.common.collect.ImmutableSet.copyOf;
import static com.google.common.collect.Iterables.transform;
import static org.jclouds.azurecompute.arm.compute.options.AzureTemplateOptions.Builder.resourceGroup;
import static org.jclouds.azurecompute.arm.config.AzureComputeProperties.TIMEOUT_RESOURCE_DELETED;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertTrue;
import java.net.URI;
import java.util.Properties;
import java.util.Set;
import org.jclouds.azurecompute.arm.AzureComputeApi;
import org.jclouds.azurecompute.arm.AzureComputeProviderMetadata;
import org.jclouds.azurecompute.arm.internal.AzureLiveTestUtils;
import org.jclouds.compute.domain.ComputeMetadata;
import org.jclouds.compute.domain.ComputeType;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.compute.domain.Template;
import org.jclouds.compute.domain.TemplateBuilder;
import org.jclouds.compute.internal.BaseComputeServiceLiveTest;
@ -40,6 +47,7 @@ import org.jclouds.sshj.config.SshjSshClientModule;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.inject.Key;
import com.google.inject.Module;
@ -67,6 +75,32 @@ public class AzureComputeServiceLiveTest extends BaseComputeServiceLiveTest {
}, Names.named(TIMEOUT_RESOURCE_DELETED)));
}
// Base method performs Iterables.elementsEqual which is case sensitive.
// Azure API can return values in different cases so we'll perform a custom validation
@Override
@Test(dependsOnMethods = "testSuspendResume")
public void testListNodesByIds() {
final Set<String> nodeIds = copyOf(transform(nodes, new Function<NodeMetadata, String>() {
@Override
public String apply(NodeMetadata from) {
return from.getId();
}
}));
final Set<? extends ComputeMetadata> listedNodes = client.listNodesByIds(nodeIds);
assertEquals(listedNodes.size(), nodes.size());
for (ComputeMetadata listedNode : listedNodes) {
assert listedNode.getProviderId() != null : listedNode;
assert listedNode.getLocation() != null : listedNode;
assertEquals(listedNode.getType(), ComputeType.NODE);
assert nodeIds.contains(listedNode.getId());
}
}
@Override
@AfterClass(groups = "live", alwaysRun = true)
protected void tearDownContext() {

View File

@ -193,6 +193,41 @@ public class VirtualMachineApiLiveTest extends BaseAzureComputeApiLiveTest {
assertTrue(vmPresent);
}
@Test(dependsOnMethods = "testCreate")
public void testListAll() {
List<VirtualMachine> list = api.getVirtualMachineApi(null).listAll();
final VirtualMachine vm = api().get(vmName);
boolean vmPresent = Iterables.any(list, new Predicate<VirtualMachine>() {
public boolean apply(VirtualMachine input) {
return input.name().equals(vm.name());
}
});
assertTrue(vmPresent);
}
@Test(dependsOnMethods = "testCreate")
public void testListByLocation() {
List<VirtualMachine> list = api.getVirtualMachineApi(null).listByLocation(LOCATION);
final VirtualMachine vm = api().get(vmName);
boolean vmPresent = Iterables.any(list, new Predicate<VirtualMachine>() {
public boolean apply(VirtualMachine input) {
return input.name().equals(vm.name());
}
});
assertTrue(vmPresent);
boolean vmsInOtherLocations = Iterables.any(list, new Predicate<VirtualMachine>() {
public boolean apply(VirtualMachine input) {
return !input.location().equals(LOCATION);
}
});
assertFalse(vmsInOtherLocations);
}
@Test(dependsOnMethods = "testCreate")
public void testListAvailableSizes() {
List<VMSize> vmSizes = api().listAvailableSizes(vmName);

View File

@ -104,7 +104,7 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {
}
public void testList() throws Exception {
server.enqueue(jsonResponse("/virtualmachines.json"));
server.enqueue(jsonResponse("/virtualmachinesinresourcegroup.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
assertEquals(vmAPI.list(), getVMList());
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute"
@ -119,6 +119,22 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {
+ "/virtualMachines?api-version=2018-06-01");
}
public void testListAll() throws Exception {
server.enqueue(jsonResponse("/virtualmachinesinsubscription.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi(null);
assertEquals(vmAPI.listAll(), getVMListAll());
assertSent(server, "GET",
"/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/virtualMachines?api-version=2018-06-01");
}
public void testListByLocation() throws Exception {
server.enqueue(jsonResponse("/virtualmachinesinlocation.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi(null);
assertEquals(vmAPI.listByLocation("testlocation"), getVMListByLocation()); // TODO bylocation
assertSent(server, "GET", "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/testlocation"
+ "/virtualMachines?api-version=2018-06-01");
}
public void testListAvailableSizes() throws Exception {
server.enqueue(jsonResponse("/virtualmachineavailablesizes.json"));
final VirtualMachineApi vmAPI = api.getVirtualMachineApi("groupname");
@ -429,4 +445,51 @@ public class VirtualMachineApiMockTest extends BaseAzureComputeApiMockTest {
return list;
}
private List<VirtualMachine> getVMListAll() {
List<VirtualMachine> list = new ArrayList<VirtualMachine>();
VirtualMachineProperties propertiesWithManagedDisks = getVMWithManagedDisksProperties();
VirtualMachine machineWithManagedDisks = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + ""
+ "resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine",
"Microsoft.Compute/virtualMachines", "westus", null, propertiesWithManagedDisks, null);
list.add(machineWithManagedDisks);
VirtualMachineProperties propertiesWithBlobDisks = getVMWithBlobDisksProperties();
VirtualMachine machineWithBlobDisks = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + ""
+ "resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine",
"Microsoft.Compute/virtualMachines", "westus", null, propertiesWithBlobDisks, null);
list.add(machineWithBlobDisks);
VirtualMachine machineInDifferentResourceGroup = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + ""
+ "resourceGroups/otherresourcegroup/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine", "Microsoft.Compute/virtualMachines", "westus", null, propertiesWithBlobDisks, null);
list.add(machineInDifferentResourceGroup);
VirtualMachine machineInDifferentLocation = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + ""
+ "resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine",
"Microsoft.Compute/virtualMachines", "eastus", null, propertiesWithBlobDisks, null);
list.add(machineInDifferentLocation);
return list;
}
private List<VirtualMachine> getVMListByLocation() {
List<VirtualMachine> list = new ArrayList<VirtualMachine>();
VirtualMachineProperties propertiesWithManagedDisks = getVMWithManagedDisksProperties();
VirtualMachine machineWithManagedDisks = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + ""
+ "resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine",
"Microsoft.Compute/virtualMachines", "westus", null, propertiesWithManagedDisks, null);
list.add(machineWithManagedDisks);
VirtualMachineProperties propertiesWithBlobDisks = getVMWithBlobDisksProperties();
VirtualMachine machineWithBlobDisks = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + ""
+ "resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine",
"Microsoft.Compute/virtualMachines", "westus", null, propertiesWithBlobDisks, null);
list.add(machineWithBlobDisks);
VirtualMachine machineInDifferentResourceGroup = VirtualMachine.create("/subscriptions/SUBSCRIPTIONID/" + ""
+ "resourceGroups/otherresourcegroup/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"windowsmachine", "Microsoft.Compute/virtualMachines", "westus", null, propertiesWithBlobDisks, null);
list.add(machineInDifferentResourceGroup);
return list;
}
}

View File

@ -0,0 +1,303 @@
{
"value": [
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"licenseType": "Windows_Server",
"availabilitySet":{
"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet"
},
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "OFFER",
"sku": "sku",
"version": "ver",
"id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/westus/publishers/MicrosoftWindowsServerEssentials/artifactype/vmimage/offers/OFFER/skus/OFFER/versions/latest"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
},
"caching": "ReadWrite"
},
"dataDisks":[
{
"name":"mydatadisk1",
"diskSizeGB":"1",
"lun": 0,
"createOption":"Empty",
"caching":"ReadWrite",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
}
}
]
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"adminPassword":"password",
"customData":"",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true,
"winRM": {
"listeners":[{
"protocol": "https",
"certificateUrl": "url-to-certificate"
}]
},
"additionalUnattendContent":[
{
"passName":"oobesystem",
"componentName":"Microsoft-Windows-Shell-Setup",
"settingName":"FirstLogonCommands",
"content":"<XML unattend content>"
}
]
},
"secrets":[
{
"sourceVault": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/Microsoft.KeyVault/vaults/myvault1"
},
"vaultCertificates": [
{
"certificateUrl": "https://myvault1.vault.azure.net/secrets/SECRETNAME/SECRETVERSION",
"certificateStore": "CERTIFICATESTORENAME"
}
]
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
},
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"licenseType": "Windows_Server",
"availabilitySet":{
"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet"
},
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "OFFER",
"sku": "sku",
"version": "ver",
"id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/westus/publishers/MicrosoftWindowsServerEssentials/artifactype/vmimage/offers/OFFER/skus/OFFER/versions/latest"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
},
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks":[
{
"name":"mydatadisk1",
"diskSizeGB":"1",
"lun": 0,
"vhd": {
"uri" : "http://mystorage1.blob.core.windows.net/vhds/mydatadisk1.vhd"
},
"createOption":"Empty"
}
]
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"adminPassword":"password",
"customData":"",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true,
"winRM": {
"listeners":[{
"protocol": "https",
"certificateUrl": "url-to-certificate"
}]
},
"additionalUnattendContent":[
{
"passName":"oobesystem",
"componentName":"Microsoft-Windows-Shell-Setup",
"settingName":"FirstLogonCommands",
"content":"<XML unattend content>"
}
]
},
"secrets":[
{
"sourceVault": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/Microsoft.KeyVault/vaults/myvault1"
},
"vaultCertificates": [
{
"certificateUrl": "https://myvault1.vault.azure.net/secrets/SECRETNAME/SECRETVERSION",
"certificateStore": "CERTIFICATESTORENAME"
}
]
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
},
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"licenseType": "Windows_Server",
"availabilitySet":{
"id":"/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet"
},
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "OFFER",
"sku": "sku",
"version": "ver",
"id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/westus/publishers/MicrosoftWindowsServerEssentials/artifactype/vmimage/offers/OFFER/skus/OFFER/versions/latest"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
},
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks":[
{
"name":"mydatadisk1",
"diskSizeGB":"1",
"lun": 0,
"vhd": {
"uri" : "http://mystorage1.blob.core.windows.net/vhds/mydatadisk1.vhd"
},
"createOption":"Empty"
}
]
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"adminPassword":"password",
"customData":"",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true,
"winRM": {
"listeners":[{
"protocol": "https",
"certificateUrl": "url-to-certificate"
}]
},
"additionalUnattendContent":[
{
"passName":"oobesystem",
"componentName":"Microsoft-Windows-Shell-Setup",
"settingName":"FirstLogonCommands",
"content":"<XML unattend content>"
}
]
},
"secrets":[
{
"sourceVault": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/Microsoft.KeyVault/vaults/myvault1"
},
"vaultCertificates": [
{
"certificateUrl": "https://myvault1.vault.azure.net/secrets/SECRETNAME/SECRETVERSION",
"certificateStore": "CERTIFICATESTORENAME"
}
]
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/otherresourcegroup/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
}
]
}

View File

@ -0,0 +1,411 @@
{
"value": [
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"licenseType": "Windows_Server",
"availabilitySet": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet"
},
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "OFFER",
"sku": "sku",
"version": "ver",
"id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/westus/publishers/MicrosoftWindowsServerEssentials/artifactype/vmimage/offers/OFFER/skus/OFFER/versions/latest"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
},
"caching": "ReadWrite"
},
"dataDisks": [
{
"name": "mydatadisk1",
"diskSizeGB": "1",
"lun": 0,
"createOption": "Empty",
"caching": "ReadWrite",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
}
}
]
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"adminPassword": "password",
"customData": "",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true,
"winRM": {
"listeners": [
{
"protocol": "https",
"certificateUrl": "url-to-certificate"
}
]
},
"additionalUnattendContent": [
{
"passName": "oobesystem",
"componentName": "Microsoft-Windows-Shell-Setup",
"settingName": "FirstLogonCommands",
"content": "<XML unattend content>"
}
]
},
"secrets": [
{
"sourceVault": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/Microsoft.KeyVault/vaults/myvault1"
},
"vaultCertificates": [
{
"certificateUrl": "https://myvault1.vault.azure.net/secrets/SECRETNAME/SECRETVERSION",
"certificateStore": "CERTIFICATESTORENAME"
}
]
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
},
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"licenseType": "Windows_Server",
"availabilitySet": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet"
},
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "OFFER",
"sku": "sku",
"version": "ver",
"id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/westus/publishers/MicrosoftWindowsServerEssentials/artifactype/vmimage/offers/OFFER/skus/OFFER/versions/latest"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
},
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks": [
{
"name": "mydatadisk1",
"diskSizeGB": "1",
"lun": 0,
"vhd": {
"uri": "http://mystorage1.blob.core.windows.net/vhds/mydatadisk1.vhd"
},
"createOption": "Empty"
}
]
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"adminPassword": "password",
"customData": "",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true,
"winRM": {
"listeners": [
{
"protocol": "https",
"certificateUrl": "url-to-certificate"
}
]
},
"additionalUnattendContent": [
{
"passName": "oobesystem",
"componentName": "Microsoft-Windows-Shell-Setup",
"settingName": "FirstLogonCommands",
"content": "<XML unattend content>"
}
]
},
"secrets": [
{
"sourceVault": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/Microsoft.KeyVault/vaults/myvault1"
},
"vaultCertificates": [
{
"certificateUrl": "https://myvault1.vault.azure.net/secrets/SECRETNAME/SECRETVERSION",
"certificateStore": "CERTIFICATESTORENAME"
}
]
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
},
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"licenseType": "Windows_Server",
"availabilitySet": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet"
},
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "OFFER",
"sku": "sku",
"version": "ver",
"id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/westus/publishers/MicrosoftWindowsServerEssentials/artifactype/vmimage/offers/OFFER/skus/OFFER/versions/latest"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
},
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks": [
{
"name": "mydatadisk1",
"diskSizeGB": "1",
"lun": 0,
"vhd": {
"uri": "http://mystorage1.blob.core.windows.net/vhds/mydatadisk1.vhd"
},
"createOption": "Empty"
}
]
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"adminPassword": "password",
"customData": "",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true,
"winRM": {
"listeners": [
{
"protocol": "https",
"certificateUrl": "url-to-certificate"
}
]
},
"additionalUnattendContent": [
{
"passName": "oobesystem",
"componentName": "Microsoft-Windows-Shell-Setup",
"settingName": "FirstLogonCommands",
"content": "<XML unattend content>"
}
]
},
"secrets": [
{
"sourceVault": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/Microsoft.KeyVault/vaults/myvault1"
},
"vaultCertificates": [
{
"certificateUrl": "https://myvault1.vault.azure.net/secrets/SECRETNAME/SECRETVERSION",
"certificateStore": "CERTIFICATESTORENAME"
}
]
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/otherresourcegroup/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "westus"
},
{
"properties": {
"vmId": "27ee085b-d707-xxxx-yyyy-2370e2eb1cc1",
"licenseType": "Windows_Server",
"availabilitySet": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/availabilitySets/myAVSet"
},
"hardwareProfile": {
"vmSize": "Standard_D1"
},
"storageProfile": {
"imageReference": {
"publisher": "publisher",
"offer": "OFFER",
"sku": "sku",
"version": "ver",
"id": "/subscriptions/SUBSCRIPTIONID/providers/Microsoft.Compute/locations/westus/publishers/MicrosoftWindowsServerEssentials/artifactype/vmimage/offers/OFFER/skus/OFFER/versions/latest"
},
"osDisk": {
"osType": "Windows",
"name": "windowsmachine",
"createOption": "FromImage",
"managedDisk": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/osDisk",
"storageAccountType": "Standard_LRS"
},
"vhd": {
"uri": "https://groupname2760.blob.core.windows.net/vhds/windowsmachine201624102936.vhd"
},
"caching": "ReadWrite"
},
"dataDisks": [
{
"name": "mydatadisk1",
"diskSizeGB": "1",
"lun": 0,
"vhd": {
"uri": "http://mystorage1.blob.core.windows.net/vhds/mydatadisk1.vhd"
},
"createOption": "Empty"
}
]
},
"osProfile": {
"computerName": "windowsmachine",
"adminUsername": "azureuser",
"adminPassword": "password",
"customData": "",
"windowsConfiguration": {
"provisionVMAgent": false,
"enableAutomaticUpdates": true,
"winRM": {
"listeners": [
{
"protocol": "https",
"certificateUrl": "url-to-certificate"
}
]
},
"additionalUnattendContent": [
{
"passName": "oobesystem",
"componentName": "Microsoft-Windows-Shell-Setup",
"settingName": "FirstLogonCommands",
"content": "<XML unattend content>"
}
]
},
"secrets": [
{
"sourceVault": {
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/myresourcegroup1/providers/Microsoft.KeyVault/vaults/myvault1"
},
"vaultCertificates": [
{
"certificateUrl": "https://myvault1.vault.azure.net/secrets/SECRETNAME/SECRETVERSION",
"certificateStore": "CERTIFICATESTORENAME"
}
]
}
]
},
"networkProfile": {
"networkInterfaces": [
{
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Network/networkInterfaces/windowsmachine167"
}
]
},
"diagnosticsProfile": {
"bootDiagnostics": {
"enabled": true,
"storageUri": "https://groupname2760.blob.core.windows.net/"
}
},
"provisioningState": "Creating"
},
"id": "/subscriptions/SUBSCRIPTIONID/resourceGroups/groupname/providers/Microsoft.Compute/virtualMachines/windowsmachine",
"name": "windowsmachine",
"type": "Microsoft.Compute/virtualMachines",
"location": "eastus"
}
]
}