Search in sources :

Example 1 with DeploymentSlot

use of com.microsoft.azure.management.appservice.DeploymentSlot in project azure-sdk-for-java by Azure.

the class HostNameBindingImpl method createAsync.

@Override
public Observable<Indexable> createAsync() {
    final HostNameBinding self = this;
    Func1<HostNameBindingInner, HostNameBinding> mapper = new Func1<HostNameBindingInner, HostNameBinding>() {

        @Override
        public HostNameBinding call(HostNameBindingInner hostNameBindingInner) {
            setInner(hostNameBindingInner);
            return self;
        }
    };
    Observable<HostNameBinding> hostNameBindingObservable;
    if (parent instanceof DeploymentSlot) {
        hostNameBindingObservable = this.parent().manager().inner().webApps().createOrUpdateHostNameBindingSlotAsync(parent().resourceGroupName(), ((DeploymentSlot) parent).parent().name(), name, parent().name(), inner()).map(mapper);
    } else {
        hostNameBindingObservable = this.parent().manager().inner().webApps().createOrUpdateHostNameBindingAsync(parent().resourceGroupName(), parent().name(), name, inner()).map(mapper);
    }
    return hostNameBindingObservable.map(new Func1<HostNameBinding, Indexable>() {

        @Override
        public Indexable call(HostNameBinding hostNameBinding) {
            return hostNameBinding;
        }
    });
}
Also used : DeploymentSlot(com.microsoft.azure.management.appservice.DeploymentSlot) Indexable(com.microsoft.azure.management.resources.fluentcore.model.Indexable) Func1(rx.functions.Func1) HostNameBinding(com.microsoft.azure.management.appservice.HostNameBinding)

Example 2 with DeploymentSlot

use of com.microsoft.azure.management.appservice.DeploymentSlot in project azure-sdk-for-java by Azure.

the class ManageWebAppSlots method runSample.

/**
     * Main function which runs the actual sample.
     * @param azure instance of the azure client
     * @return true if sample runs successfully
     */
public static boolean runSample(Azure azure) {
    // New resources
    final String resourceGroupName = SdkContext.randomResourceName("rg", 24);
    final String app1Name = SdkContext.randomResourceName("webapp1-", 20);
    final String app2Name = SdkContext.randomResourceName("webapp2-", 20);
    final String app3Name = SdkContext.randomResourceName("webapp3-", 20);
    final String slotName = "staging";
    try {
        azure.resourceGroups().define(resourceGroupName).withRegion(Region.US_EAST).create();
        //============================================================
        // Create 3 web apps with 3 new app service plans in different regions
        WebApp app1 = createWebApp(azure, app1Name, Region.US_EAST, resourceGroupName);
        WebApp app2 = createWebApp(azure, app2Name, Region.EUROPE_WEST, resourceGroupName);
        WebApp app3 = createWebApp(azure, app3Name, Region.ASIA_EAST, resourceGroupName);
        //============================================================
        // Create a deployment slot under each web app with auto swap
        DeploymentSlot slot1 = createSlot(slotName, app1);
        DeploymentSlot slot2 = createSlot(slotName, app2);
        DeploymentSlot slot3 = createSlot(slotName, app3);
        //============================================================
        // Deploy the staging branch to the slot
        deployToStaging(slot1);
        deployToStaging(slot2);
        deployToStaging(slot3);
        // swap back
        swapProductionBacktoSlot(slot1);
        swapProductionBacktoSlot(slot2);
        swapProductionBacktoSlot(slot3);
        return true;
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
    } finally {
        try {
            System.out.println("Deleting Resource Group: " + resourceGroupName);
            azure.resourceGroups().beginDeleteByName(resourceGroupName);
            System.out.println("Deleted Resource Group: " + resourceGroupName);
        } catch (NullPointerException npe) {
            System.out.println("Did not create any resources in Azure. No clean up is necessary");
        } catch (Exception g) {
            g.printStackTrace();
        }
    }
    return false;
}
Also used : DeploymentSlot(com.microsoft.azure.management.appservice.DeploymentSlot) IOException(java.io.IOException) WebApp(com.microsoft.azure.management.appservice.WebApp)

Example 3 with DeploymentSlot

use of com.microsoft.azure.management.appservice.DeploymentSlot in project azure-sdk-for-java by Azure.

the class ManageWebAppSlots method createSlot.

private static DeploymentSlot createSlot(String slotName, WebApp app) {
    System.out.println("Creating a slot " + slotName + " with auto swap turned on...");
    DeploymentSlot slot = app.deploymentSlots().define(slotName).withConfigurationFromParent().withAutoSwapSlotName("production").create();
    System.out.println("Created slot " + slot.name());
    Utils.print(slot);
    return slot;
}
Also used : DeploymentSlot(com.microsoft.azure.management.appservice.DeploymentSlot)

Aggregations

DeploymentSlot (com.microsoft.azure.management.appservice.DeploymentSlot)3 HostNameBinding (com.microsoft.azure.management.appservice.HostNameBinding)1 WebApp (com.microsoft.azure.management.appservice.WebApp)1 Indexable (com.microsoft.azure.management.resources.fluentcore.model.Indexable)1 IOException (java.io.IOException)1 Func1 (rx.functions.Func1)1