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());
}
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;
}
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);
}
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;
}
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;
}
Aggregations