Search in sources :

Example 26 with StorageAccount

use of com.microsoft.azure.management.storage.StorageAccount in project azure-sdk-for-java by Azure.

the class BatchAccountImpl method handleStorageSettings.

private void handleStorageSettings() {
    StorageAccount storageAccount;
    if (this.creatableStorageAccountKey != null) {
        storageAccount = (StorageAccount) this.createdResource(this.creatableStorageAccountKey);
        existingStorageAccountToAssociate = storageAccount;
    } else if (this.existingStorageAccountToAssociate != null) {
        storageAccount = this.existingStorageAccountToAssociate;
    } else {
        return;
    }
    if (autoStorage == null) {
        autoStorage = new AutoStorageProperties();
    }
    autoStorage.withStorageAccountId(storageAccount.id());
}
Also used : AutoStorageProperties(com.microsoft.azure.management.batch.AutoStorageProperties) StorageAccount(com.microsoft.azure.management.storage.StorageAccount)

Example 27 with StorageAccount

use of com.microsoft.azure.management.storage.StorageAccount in project azure-sdk-for-java by Azure.

the class ManageVirtualMachinesInParallel 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) {
    final int vmCount = 10;
    final Region region = Region.US_EAST;
    final String rgName = SdkContext.randomResourceName("rgCOPP", 24);
    final String networkName = SdkContext.randomResourceName("vnetCOMV", 24);
    final String storageAccountName = SdkContext.randomResourceName("stgCOMV", 20);
    final String userName = "tirekicker";
    final String password = "12NewPA$$w0rd!";
    try {
        // Create a resource group [Where all resources gets created]
        ResourceGroup resourceGroup = azure.resourceGroups().define(rgName).withRegion(region).create();
        // Prepare Creatable Network definition [Where all the virtual machines get added to]
        Creatable<Network> creatableNetwork = azure.networks().define(networkName).withRegion(region).withExistingResourceGroup(resourceGroup).withAddressSpace("172.16.0.0/16");
        // Prepare Creatable Storage account definition [For storing VMs disk]
        Creatable<StorageAccount> creatableStorageAccount = azure.storageAccounts().define(storageAccountName).withRegion(region).withExistingResourceGroup(resourceGroup);
        // Prepare a batch of Creatable Virtual Machines definitions
        List<Creatable<VirtualMachine>> creatableVirtualMachines = new ArrayList<>();
        for (int i = 0; i < vmCount; i++) {
            Creatable<VirtualMachine> creatableVirtualMachine = azure.virtualMachines().define("VM-" + i).withRegion(region).withExistingResourceGroup(resourceGroup).withNewPrimaryNetwork(creatableNetwork).withPrimaryPrivateIPAddressDynamic().withoutPrimaryPublicIPAddress().withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS).withRootUsername(userName).withRootPassword(password).withSize(VirtualMachineSizeTypes.STANDARD_DS3_V2).withNewStorageAccount(creatableStorageAccount);
            creatableVirtualMachines.add(creatableVirtualMachine);
        }
        StopWatch stopwatch = new StopWatch();
        System.out.println("Creating the virtual machines");
        stopwatch.start();
        Collection<VirtualMachine> virtualMachines = azure.virtualMachines().create(creatableVirtualMachines).values();
        stopwatch.stop();
        System.out.println("Created virtual machines");
        for (VirtualMachine virtualMachine : virtualMachines) {
            System.out.println(virtualMachine.id());
        }
        System.out.println("Virtual Machines create: (took " + (stopwatch.getTime() / 1000) + " seconds) ");
        return true;
    } catch (Exception f) {
        System.out.println(f.getMessage());
        f.printStackTrace();
    } finally {
        try {
            System.out.println("Deleting Resource Group: " + rgName);
            azure.resourceGroups().beginDeleteByName(rgName);
        } 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 : ArrayList(java.util.ArrayList) StopWatch(org.apache.commons.lang3.time.StopWatch) StorageAccount(com.microsoft.azure.management.storage.StorageAccount) Network(com.microsoft.azure.management.network.Network) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) Creatable(com.microsoft.azure.management.resources.fluentcore.model.Creatable) ResourceGroup(com.microsoft.azure.management.resources.ResourceGroup) VirtualMachine(com.microsoft.azure.management.compute.VirtualMachine)

Example 28 with StorageAccount

use of com.microsoft.azure.management.storage.StorageAccount in project azure-tools-for-java by Microsoft.

the class BlobExplorerFileEditorProvider method accept.

@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    StorageAccount storageAccount = virtualFile.getUserData(UIHelperImpl.STORAGE_KEY);
    ClientStorageAccount clientStorageAccount = virtualFile.getUserData(UIHelperImpl.CLIENT_STORAGE_KEY);
    BlobContainer blobContainer = virtualFile.getUserData(CONTAINER_KEY);
    return ((storageAccount != null || clientStorageAccount != null) && blobContainer != null);
}
Also used : StorageAccount(com.microsoft.azure.management.storage.StorageAccount) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) BlobContainer(com.microsoft.tooling.msservices.model.storage.BlobContainer) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)

Example 29 with StorageAccount

use of com.microsoft.azure.management.storage.StorageAccount in project azure-tools-for-java by Microsoft.

the class QueueExplorerFileEditorProvider method createEditor.

@NotNull
@Override
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    QueueFileEditor queueFileEditor = new QueueFileEditor(project);
    StorageAccount storageAccount = virtualFile.getUserData(UIHelperImpl.STORAGE_KEY);
    Queue queue = virtualFile.getUserData(QUEUE_KEY);
    queueFileEditor.setQueue(queue);
    //        queueFileEditor.setStorageAccount(storageAccount);
    queueFileEditor.fillGrid();
    return queueFileEditor;
}
Also used : StorageAccount(com.microsoft.azure.management.storage.StorageAccount) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) Queue(com.microsoft.tooling.msservices.model.storage.Queue) NotNull(org.jetbrains.annotations.NotNull)

Example 30 with StorageAccount

use of com.microsoft.azure.management.storage.StorageAccount in project azure-tools-for-java by Microsoft.

the class TableExplorerFileEditorProvider method createEditor.

@NotNull
@Override
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
    TableFileEditor tableFileEditor = new TableFileEditor(project);
    StorageAccount storageAccount = virtualFile.getUserData(UIHelperImpl.STORAGE_KEY);
    Table table = virtualFile.getUserData(TABLE_KEY);
    tableFileEditor.setTable(table);
    //        tableFileEditor.setStorageAccount(storageAccount);
    tableFileEditor.fillGrid();
    return tableFileEditor;
}
Also used : Table(com.microsoft.tooling.msservices.model.storage.Table) StorageAccount(com.microsoft.azure.management.storage.StorageAccount) ClientStorageAccount(com.microsoft.tooling.msservices.model.storage.ClientStorageAccount) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

StorageAccount (com.microsoft.azure.management.storage.StorageAccount)30 ResourceGroup (com.microsoft.azure.management.resources.ResourceGroup)9 ArrayList (java.util.ArrayList)8 ClientStorageAccount (com.microsoft.tooling.msservices.model.storage.ClientStorageAccount)7 VirtualMachine (com.microsoft.azure.management.compute.VirtualMachine)5 Network (com.microsoft.azure.management.network.Network)5 Region (com.microsoft.azure.management.resources.fluentcore.arm.Region)5 Creatable (com.microsoft.azure.management.resources.fluentcore.model.Creatable)5 StorageAccountKey (com.microsoft.azure.management.storage.StorageAccountKey)5 Test (org.junit.Test)5 Func1 (rx.functions.Func1)4 Indexable (com.microsoft.azure.management.resources.fluentcore.model.Indexable)3 CloudStorageAccount (com.microsoft.azure.storage.CloudStorageAccount)3 CloudBlobContainer (com.microsoft.azure.storage.blob.CloudBlobContainer)3 StopWatch (org.apache.commons.lang3.time.StopWatch)3 CloudException (com.microsoft.azure.CloudException)2 WebApp (com.microsoft.azure.management.appservice.WebApp)2 PublicIPAddress (com.microsoft.azure.management.network.PublicIPAddress)2 Resource (com.microsoft.azure.management.resources.fluentcore.arm.models.Resource)2 StorageAccounts (com.microsoft.azure.management.storage.StorageAccounts)2