com.microsoft.azure.management.resources.fluentcore.arm.AvailabilityZoneId Java Examples

The following examples show how to use com.microsoft.azure.management.resources.fluentcore.arm.AvailabilityZoneId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VirtualMachineImpl.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
@Override
public VirtualMachineImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
    if (isInCreateMode()) {
        // Note: Zone is not updatable as of now, so this is available only during definition time.
        // Service return `ResourceAvailabilityZonesCannotBeModified` upon attempt to append a new
        // zone or remove one. Trying to remove the last one means attempt to change resource from
        // zonal to regional, which is not supported.
        //
        // though not updatable, still adding above 'isInCreateMode' check just as a reminder to
        // take special handling of 'implicitPipCreatable' when avail zone update is supported.
        //
        if (this.inner().zones() == null) {
            this.inner().withZones(new ArrayList<String>());
        }
        this.inner().zones().add(zoneId.toString());
        // zone aware VM can be attached to only zone aware public IP.
        //
        if (this.implicitPipCreatable != null) {
            this.implicitPipCreatable.withAvailabilityZone(zoneId);
        }
    }
    return this;
}
 
Example #2
Source File: ComputeSkuImpl.java    From azure-libraries-for-java with MIT License 6 votes vote down vote up
@Override
public Map<Region, Set<AvailabilityZoneId>> zones() {
    Map<Region, Set<AvailabilityZoneId>> regionToZones = new HashMap<>();
    if (this.inner.locationInfo() != null) {
        for (ResourceSkuLocationInfo info : this.inner.locationInfo()) {
            if (info.location() != null) {
                Region region = Region.fromName(info.location());
                if (!regionToZones.containsKey(region)) {
                    regionToZones.put(region, new HashSet<AvailabilityZoneId>());
                }
                Set<AvailabilityZoneId> availabilityZoneIds = new HashSet<>();
                if (info.zones() != null) {
                    for (String zone : info.zones()) {
                        availabilityZoneIds.add(AvailabilityZoneId.fromString(zone));
                    }
                }
                regionToZones.get(region).addAll(availabilityZoneIds);
            }
        }
    }
    return regionToZones;
}
 
Example #3
Source File: ListComputeSkus.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
private static String regionZoneToString(Map<Region, Set<AvailabilityZoneId>> regionZonesMap) {
    StringBuilder builder = new StringBuilder();
    for (Map.Entry<Region, Set<AvailabilityZoneId>> regionZones : regionZonesMap.entrySet()) {
        builder.append(regionZones.getKey().toString());
        builder.append(" [ ");
        for (AvailabilityZoneId zone :regionZones.getValue()) {
            builder.append(zone).append(" ");
        }
        builder.append("] ");
    }
    return builder.toString();
}
 
Example #4
Source File: ApplicationGatewayImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public ApplicationGatewayImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
    if (this.inner().zones() == null) {
        this.inner().withZones(new ArrayList<String>());
    }
    if (!this.inner().zones().contains(zoneId.toString())) {
        this.inner().zones().add(zoneId.toString());
    }
    return this;
}
 
Example #5
Source File: ApplicationGatewayImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new TreeSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example #6
Source File: PublicIPAddressImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public PublicIPAddressImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
    // Note: Zone is not updatable as of now, so this is available only during definition time.
    // Service return `ResourceAvailabilityZonesCannotBeModified` upon attempt to append a new
    // zone or remove one. Trying to remove the last one means attempt to change resource from
    // zonal to regional, which is not supported.
    //
    if (this.inner().zones() == null) {
        this.inner().withZones(new ArrayList<String>());
    }
    this.inner().zones().add(zoneId.toString());
    return this;
}
 
Example #7
Source File: PublicIPAddressImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new HashSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example #8
Source File: VirtualMachineImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new HashSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example #9
Source File: DiskImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public DiskImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
    // Note: Zone is not updatable as of now, so this is available only during definition time.
    // Service return `ResourceAvailabilityZonesCannotBeModified` upon attempt to append a new
    // zone or remove one. Trying to remove the last one means attempt to change resource from
    // zonal to regional, which is not supported.
    if (this.inner().zones() == null) {
        this.inner().withZones(new ArrayList<String>());
    }
    this.inner().zones().add(zoneId.toString());
    return this;
}
 
Example #10
Source File: DiskImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new HashSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example #11
Source File: VirtualMachineScaleSetImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public VirtualMachineScaleSetImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
    // Note: Only for virtual machine scale set, new zone can be specified, hence
    // this option is available for both definition and update cases.
    //
    //
    if (this.inner().zones() == null) {
        this.inner().withZones(new ArrayList<String>());
    }
    this.inner().zones().add(zoneId.toString());
    return this;
}
 
Example #12
Source File: VirtualMachineScaleSetImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new HashSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example #13
Source File: LoadBalancerFrontendImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public LoadBalancerFrontendImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
    // Note: Zone is not updatable as of now, so this is available only during definition time.
    // Service return `ResourceAvailabilityZonesCannotBeModified` upon attempt to append a new
    // zone or remove one. Trying to remove the last one means attempt to change resource from
    // zonal to regional, which is not supported.
    //
    // Zone is supported only for internal load balancer, hence exposed only for PrivateFrontEnd
    //
    if (this.inner().zones() == null) {
        this.inner().withZones(new ArrayList<String>());
    }
    this.inner().zones().add(zoneId.toString());
    return this;
}
 
Example #14
Source File: LoadBalancerFrontendImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new HashSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example #15
Source File: PublicIPPrefixImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public Set<AvailabilityZoneId> availabilityZones() {
    Set<AvailabilityZoneId> zones = new HashSet<>();
    if (this.inner().zones() != null) {
        for (String zone : this.inner().zones()) {
            zones.add(AvailabilityZoneId.fromString(zone));
        }
    }
    return Collections.unmodifiableSet(zones);
}
 
Example #16
Source File: PublicIPPrefixImpl.java    From azure-libraries-for-java with MIT License 5 votes vote down vote up
@Override
public PublicIPPrefixImpl withAvailabilityZone(AvailabilityZoneId zoneId) {
    // Note: Zone is not updatable as of now, so this is available only during definition time.
    // Service return `ResourceAvailabilityZonesCannotBeModified` upon attempt to append a new
    // zone or remove one. Trying to remove the last one means attempt to change resource from
    // zonal to regional, which is not supported.
    //
    if (this.inner().zones() == null) {
        this.inner().withZones(new ArrayList<String>());
    }
    this.inner().zones().add(zoneId.toString());
    return this;
}
 
Example #17
Source File: AzureVolumeResourceBuilder.java    From cloudbreak with Apache License 2.0 5 votes vote down vote up
private String getAvailabilityZone(AuthenticatedContext auth, CloudResource vm) {
    LOGGER.debug("Fetching availability zone for vm {}", vm.getName());
    AzureClient client = getAzureClient(auth);
    String vmName = vm.getName();
    String resourceGroupName = azureResourceGroupMetadataProvider.getResourceGroupName(auth.getCloudContext(), vm);

    // Azure Java client returns a Set, but VM can only have at most 1 AZ
    return client.getAvailabilityZone(resourceGroupName, vmName).stream()
            .findFirst()
            .map(AvailabilityZoneId::toString)
            .orElse(null);
}
 
Example #18
Source File: VirtualMachineScaleSetOperationsTests.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Test
public void canCreateZoneRedundantVirtualMachineScaleSetWithZoneResilientLoadBalancer() throws Exception {
    // Zone redundant VMSS is the one with multiple zones
    //

    Region REGION2 = Region.US_EAST2;

    ResourceGroup resourceGroup = this.resourceManager.resourceGroups()
            .define(RG_NAME)
            .withRegion(REGION2)
            .create();

    Network network = this.networkManager
            .networks()
            .define("vmssvnet")
            .withRegion(REGION2)
            .withExistingResourceGroup(resourceGroup)
            .withAddressSpace("10.0.0.0/28")
            .withSubnet("subnet1", "10.0.0.0/28")
            .create();

    // Zone redundant VMSS requires STANDARD LB
    //
    // Creates a STANDARD LB with one public frontend ip configuration with two backend pools
    // Each address pool of STANDARD LB can hold different VMSS resource.
    //
    LoadBalancer publicLoadBalancer = createInternetFacingLoadBalancer(REGION2,
            resourceGroup,
            "1",
            LoadBalancerSkuType.STANDARD);

    List<String> backends = new ArrayList<>();
    for (String backend : publicLoadBalancer.backends().keySet()) {
        backends.add(backend);
    }
    Assert.assertTrue(backends.size() == 2);

    final String vmss_name = generateRandomResourceName("vmss", 10);
    // HTTP & HTTPS traffic on port 80, 443 of Internet-facing LB goes to corresponding port in virtual machine scale set
    //
    VirtualMachineScaleSet virtualMachineScaleSet = this.computeManager.virtualMachineScaleSets()
            .define(vmss_name)
            .withRegion(REGION2)
            .withExistingResourceGroup(resourceGroup)
            .withSku(VirtualMachineScaleSetSkuTypes.STANDARD_D3_V2)
            .withExistingPrimaryNetworkSubnet(network, "subnet1")
            .withExistingPrimaryInternetFacingLoadBalancer(publicLoadBalancer)
            .withPrimaryInternetFacingLoadBalancerBackends(backends.get(0), backends.get(1))
            .withoutPrimaryInternalLoadBalancer()
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername("jvuser")
            .withRootPassword("123OData!@#123")
            .withAvailabilityZone(AvailabilityZoneId.ZONE_1)  // Zone redundant - zone 1 + zone 2
            .withAvailabilityZone(AvailabilityZoneId.ZONE_2)
            .create();

    // Check zones
    //
    Assert.assertNotNull(virtualMachineScaleSet.availabilityZones());
    Assert.assertEquals(2, virtualMachineScaleSet.availabilityZones().size());

    // Validate Network specific properties (LB, VNet, NIC, IPConfig etc..)
    //
    Assert.assertNull(virtualMachineScaleSet.getPrimaryInternalLoadBalancer());
    Assert.assertTrue(virtualMachineScaleSet.listPrimaryInternalLoadBalancerBackends().size() == 0);
    Assert.assertTrue(virtualMachineScaleSet.listPrimaryInternalLoadBalancerInboundNatPools().size() == 0);

    Assert.assertNotNull(virtualMachineScaleSet.getPrimaryInternetFacingLoadBalancer());
    Assert.assertTrue(virtualMachineScaleSet.listPrimaryInternetFacingLoadBalancerBackends().size() == 2);
    Assert.assertTrue(virtualMachineScaleSet.listPrimaryInternetFacingLoadBalancerInboundNatPools().size() == 2);

    Network primaryNetwork = virtualMachineScaleSet.getPrimaryNetwork();
    Assert.assertNotNull(primaryNetwork.id());
}
 
Example #19
Source File: VirtualMachineVH.java    From pacbot with Apache License 2.0 4 votes vote down vote up
public Set<AvailabilityZoneId> getAvailabilityZones() {
	return availabilityZones;
}
 
Example #20
Source File: AzureClient.java    From cloudbreak with Apache License 2.0 4 votes vote down vote up
public Set<AvailabilityZoneId> getAvailabilityZone(String resourceGroup, String vmName) {
    return handleAuthException(() -> {
        VirtualMachine vm = azure.virtualMachines().getByResourceGroup(resourceGroup, vmName);
        return Objects.nonNull(vm) ? vm.availabilityZones() : Collections.emptySet();
    });
}
 
Example #21
Source File: VirtualMachineAvailabilityZoneOperationsTests.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Test
public void canCreateZonedVirtualMachineWithExplicitZoneForRelatedResources() throws Exception {
    // Create zoned public IP for the virtual machine
    //
    final String pipDnsLabel = generateRandomResourceName("pip", 10);
    PublicIPAddress publicIPAddress = networkManager.publicIPAddresses()
            .define(pipDnsLabel)
            .withRegion(REGION)
            .withNewResourceGroup(RG_NAME)
            .withStaticIP()
            // Optionals
            .withAvailabilityZone(AvailabilityZoneId.ZONE_1)  // since the SKU is BASIC and VM is zoned, PIP must be zoned
            .withSku(PublicIPSkuType.BASIC)    // Basic sku is never zone resilient, so if you want it zoned, specify explicitly as above.
            // Create PIP
            .create();
    // Create a zoned data disk for the virtual machine
    //
    final String diskName = generateRandomResourceName("dsk", 10);
    Disk dataDisk = computeManager.disks()
            .define(diskName)
            .withRegion(REGION)
            .withExistingResourceGroup(RG_NAME)
            .withData()
            .withSizeInGB(100)
            // Optionals
            .withAvailabilityZone(AvailabilityZoneId.ZONE_1)
            // Create Disk
            .create();
    // Create a zoned virtual machine
    //
    VirtualMachine virtualMachine = computeManager.virtualMachines()
            .define(VMNAME)
            .withRegion(REGION)
            .withNewResourceGroup(RG_NAME)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withExistingPrimaryPublicIPAddress(publicIPAddress)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername("Foo12")
            .withRootPassword("abc!@#F0orL")
            // Optionals
            .withAvailabilityZone(AvailabilityZoneId.ZONE_1)
            .withExistingDataDisk(dataDisk)
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            // Create VM
            .create();
    // Checks the zone assigned to the virtual machine
    //
    Assert.assertNotNull(virtualMachine.availabilityZones());
    Assert.assertFalse(virtualMachine.availabilityZones().isEmpty());
    Assert.assertTrue(virtualMachine.availabilityZones().contains(AvailabilityZoneId.ZONE_1));
    // Checks the zone assigned to the explicitly created public IP address.
    //
    publicIPAddress = virtualMachine.getPrimaryPublicIPAddress();
    Assert.assertNotNull(publicIPAddress.sku());
    Assert.assertTrue(publicIPAddress.sku().equals(PublicIPSkuType.BASIC));
    Assert.assertNotNull(publicIPAddress.availabilityZones());
    Assert.assertFalse(publicIPAddress.availabilityZones().isEmpty());
    Assert.assertTrue(publicIPAddress.availabilityZones().contains(AvailabilityZoneId.ZONE_1));
    // Check the zone assigned to the explicitly created data disk
    //
    Map<Integer, VirtualMachineDataDisk> dataDisks = virtualMachine.dataDisks();
    Assert.assertNotNull(dataDisks);
    Assert.assertFalse(dataDisks.isEmpty());
    VirtualMachineDataDisk dataDisk1 = dataDisks.values().iterator().next();
    Assert.assertNotNull(dataDisk1.id());
    dataDisk = computeManager.disks().getById(dataDisk1.id());
    Assert.assertNotNull(dataDisk);
    Assert.assertNotNull(dataDisk.availabilityZones());
    Assert.assertFalse(dataDisk.availabilityZones().isEmpty());
    Assert.assertTrue(dataDisk.availabilityZones().contains(AvailabilityZoneId.ZONE_1));
    // Checks the zone assigned to the implicitly created managed OS disk.
    //
    String osDiskId = virtualMachine.osDiskId();    // Only VM based on managed disk can have zone assigned
    Assert.assertNotNull(osDiskId);
    Assert.assertFalse(osDiskId.isEmpty());
    Disk osDisk = computeManager.disks().getById(osDiskId);
    Assert.assertNotNull(osDisk);
    // Checks the zone assigned to the implicitly created managed OS disk.
    //
    Assert.assertNotNull(osDisk.availabilityZones());
    Assert.assertFalse(osDisk.availabilityZones().isEmpty());
    Assert.assertTrue(osDisk.availabilityZones().contains(AvailabilityZoneId.ZONE_1));
}
 
Example #22
Source File: VirtualMachineVH.java    From pacbot with Apache License 2.0 4 votes vote down vote up
public void setAvailabilityZones(Set<AvailabilityZoneId> availabilityZones) {
	this.availabilityZones = availabilityZones;
}
 
Example #23
Source File: VirtualMachineAvailabilityZoneOperationsTests.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Test
public void canCreateZonedVirtualMachineWithImplicitZoneForRelatedResources() throws Exception {
    final String pipDnsLabel = generateRandomResourceName("pip", 10);
    final String proxyGroupName = "plg1Test";
    // Create a zoned virtual machine
    //
    VirtualMachine virtualMachine = computeManager.virtualMachines()
            .define(VMNAME)
            .withRegion(REGION)
            .withNewResourceGroup(RG_NAME)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(pipDnsLabel)
            .withNewProximityPlacementGroup(proxyGroupName, ProximityPlacementGroupType.STANDARD)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername("Foo12")
            .withRootPassword("abc!@#F0orL")
            // Optionals
            .withAvailabilityZone(AvailabilityZoneId.ZONE_1)
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            .withOSDiskCaching(CachingTypes.READ_WRITE)
            // Create VM
            .create();

    // Checks the zone assigned to the virtual machine
    //
    Assert.assertNotNull(virtualMachine.availabilityZones());
    Assert.assertFalse(virtualMachine.availabilityZones().isEmpty());
    Assert.assertTrue(virtualMachine.availabilityZones().contains(AvailabilityZoneId.ZONE_1));

    //Check the proximity placement group information
    Assert.assertNotNull(virtualMachine.proximityPlacementGroup());
    Assert.assertEquals(ProximityPlacementGroupType.STANDARD, virtualMachine.proximityPlacementGroup().proximityPlacementGroupType());
    Assert.assertNotNull(virtualMachine.proximityPlacementGroup().virtualMachineIds());
    Assert.assertTrue(virtualMachine.id().equalsIgnoreCase(virtualMachine.proximityPlacementGroup().virtualMachineIds().get(0)));

    // Checks the zone assigned to the implicitly created public IP address.
    // Implicitly created PIP will be BASIC
    //
    PublicIPAddress publicIPAddress = virtualMachine.getPrimaryPublicIPAddress();
    Assert.assertNotNull(publicIPAddress.availabilityZones());
    Assert.assertFalse(publicIPAddress.availabilityZones().isEmpty());
    Assert.assertTrue(publicIPAddress.availabilityZones().contains(AvailabilityZoneId.ZONE_1));
    // Checks the zone assigned to the implicitly created managed OS disk.
    //
    String osDiskId = virtualMachine.osDiskId();    // Only VM based on managed disk can have zone assigned
    Assert.assertNotNull(osDiskId);
    Assert.assertFalse(osDiskId.isEmpty());
    Disk osDisk = computeManager.disks().getById(osDiskId);
    Assert.assertNotNull(osDisk);
    // Checks the zone assigned to the implicitly created managed OS disk.
    //
    Assert.assertNotNull(osDisk.availabilityZones());
    Assert.assertFalse(osDisk.availabilityZones().isEmpty());
    Assert.assertTrue(osDisk.availabilityZones().contains(AvailabilityZoneId.ZONE_1));
}
 
Example #24
Source File: VirtualMachineAvailabilityZoneOperationsTests.java    From azure-libraries-for-java with MIT License 4 votes vote down vote up
@Test
public void canCreateZonedVirtualMachineWithZoneResilientPublicIP() throws Exception {
    // Create zone resilient public IP for the virtual machine
    //
    final String pipDnsLabel = generateRandomResourceName("pip", 10);
    PublicIPAddress publicIPAddress = networkManager.publicIPAddresses()
            .define(pipDnsLabel)
            .withRegion(REGION)
            .withNewResourceGroup(RG_NAME)
            .withStaticIP()
            // Optionals
            .withSku(PublicIPSkuType.STANDARD)  // No zone selected, STANDARD SKU is zone resilient [zone resilient: resources deployed in all zones by the service and it will be served by all AZs all the time]
            // Create PIP
            .create();
    // Create a zoned virtual machine
    //
    VirtualMachine virtualMachine = computeManager.virtualMachines()
            .define(VMNAME)
            .withRegion(REGION)
            .withNewResourceGroup(RG_NAME)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withExistingPrimaryPublicIPAddress(publicIPAddress)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername("Foo12")
            .withRootPassword("abc!@#F0orL")
            // Optionals
            .withAvailabilityZone(AvailabilityZoneId.ZONE_1)
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            // Create VM
            .create();
    // Checks the zone assigned to the virtual machine
    //
    Assert.assertNotNull(virtualMachine.availabilityZones());
    Assert.assertFalse(virtualMachine.availabilityZones().isEmpty());
    Assert.assertTrue(virtualMachine.availabilityZones().contains(AvailabilityZoneId.ZONE_1));
    // Check the zone resilient PIP
    //
    publicIPAddress = virtualMachine.getPrimaryPublicIPAddress();
    Assert.assertNotNull(publicIPAddress.sku());
    Assert.assertTrue(publicIPAddress.sku().equals(PublicIPSkuType.STANDARD));
    Assert.assertNotNull(publicIPAddress.availabilityZones());  // Though zone-resilient, this property won't be populated by the service.
    Assert.assertTrue(publicIPAddress.availabilityZones().isEmpty());
}
 
Example #25
Source File: ComputeSku.java    From azure-libraries-for-java with MIT License 2 votes vote down vote up
/**
 * @return the availability zones supported for this sku, index by region
 */
Map<Region, Set<AvailabilityZoneId>>  zones();
 
Example #26
Source File: VirtualMachine.java    From azure-libraries-for-java with MIT License 2 votes vote down vote up
/**
 * @return the availability zones assigned to the virtual machine
 */
Set<AvailabilityZoneId> availabilityZones();
 
Example #27
Source File: VirtualMachine.java    From azure-libraries-for-java with MIT License 2 votes vote down vote up
/**
 * Specifies the availability zone for the virtual machine.
 *
 * @param zoneId the zone identifier.
 * @return the next stage of the definition
 */
WithManagedCreate withAvailabilityZone(AvailabilityZoneId zoneId);
 
Example #28
Source File: VirtualMachineScaleSet.java    From azure-libraries-for-java with MIT License 2 votes vote down vote up
/**
 * @return the availability zones assigned to virtual machine scale set.
 */
Set<AvailabilityZoneId> availabilityZones();
 
Example #29
Source File: VirtualMachineScaleSet.java    From azure-libraries-for-java with MIT License 2 votes vote down vote up
/**
 * Specifies the availability zone for the virtual machine scale set.
 *
 * @param zoneId the zone identifier.
 * @return the next stage of the definition
 */
WithManagedCreate withAvailabilityZone(AvailabilityZoneId zoneId);
 
Example #30
Source File: VirtualMachineScaleSet.java    From azure-libraries-for-java with MIT License 2 votes vote down vote up
/**
 * Specifies the availability zone for the virtual machine scale set.
 *
 * @param zoneId the zone identifier.
 * @return the next stage of the update
 */
WithApply withAvailabilityZone(AvailabilityZoneId zoneId);