Search in sources :

Example 1 with CreateResourceGroupTask

use of com.microsoft.azure.toolkit.lib.resource.task.CreateResourceGroupTask in project azure-tools-for-java by Microsoft.

the class CreateStorageAccountTask method execute.

public StorageAccount execute() {
    final Operation operation = TelemetryManager.createOperation(ActionConstants.StorageAccount.CREATE);
    try {
        operation.start();
        final String subscriptionId = config.getSubscription().getId();
        EventUtil.logEvent(EventType.info, operation, Collections.singletonMap(TelemetryConstants.SUBSCRIPTIONID, subscriptionId));
        // create resource group if necessary.
        new CreateResourceGroupTask(subscriptionId, config.getResourceGroup().getName(), config.getRegion()).execute();
        // create storage account
        return Azure.az(AzureStorageAccount.class).create(config).commit();
    } catch (final RuntimeException e) {
        EventUtil.logError(operation, ErrorType.systemError, e, null, null);
        throw e;
    } finally {
        operation.complete();
    }
}
Also used : CreateResourceGroupTask(com.microsoft.azure.toolkit.lib.resource.task.CreateResourceGroupTask) Operation(com.microsoft.azuretools.telemetrywrapper.Operation)

Aggregations

CreateResourceGroupTask (com.microsoft.azure.toolkit.lib.resource.task.CreateResourceGroupTask)1 Operation (com.microsoft.azuretools.telemetrywrapper.Operation)1