use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class BlobExplorerFileEditor method dispose.
@Override
public void dispose() {
try {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null || subscriptionListener == null) {
return;
}
azureManager.getSubscriptionManager().removeListener(subscriptionListener);
} catch (Exception ignored) {
}
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class WebAppUtils method createAppService.
public static WebApp createAppService(IProgressIndicator progressIndicator, CreateAppServiceModel model) throws IOException, WebAppException, InterruptedException, AzureCmdException {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return null;
}
Azure azure = azureManager.getAzure(model.subscriptionDetail.getSubscriptionId());
AppServicePlan appServicePlan = null;
if (model.isAppServicePlanCreateNew) {
AppServicePlan.DefinitionStages.WithGroup ds1 = azure.appServices().appServicePlans().define(model.appServicePlanNameCreateNew).withRegion(model.appServicePlanLocationCreateNew.name());
AppServicePlan.DefinitionStages.WithPricingTier ds2;
if (model.isResourceGroupCreateNew) {
ds2 = ds1.withNewResourceGroup(model.resourceGroupNameCreateNew);
} else {
ds2 = ds1.withExistingResourceGroup(model.resourceGroup);
}
appServicePlan = ds2.withPricingTier(model.appServicePricingTierCreateNew).withOperatingSystem(OperatingSystem.WINDOWS).create();
} else {
appServicePlan = model.appServicePlan;
}
WebApp.DefinitionStages.Blank definitionStages = azure.webApps().define(model.webAppName);
WebAppBase.DefinitionStages.WithCreate<WebApp> withCreate;
WebApp.DefinitionStages.ExistingWindowsPlanWithGroup ds1 = definitionStages.withExistingWindowsPlan(appServicePlan);
if (model.isResourceGroupCreateNew) {
withCreate = ds1.withNewResourceGroup(model.resourceGroupNameCreateNew);
} else {
withCreate = ds1.withExistingResourceGroup(model.resourceGroup);
}
if (model.jdkDownloadUrl == null) {
// no custom jdk
withCreate = withCreate.withJavaVersion(JavaVersion.JAVA_8_NEWEST).withWebContainer(model.webContainer);
}
WebApp myWebApp = withCreate.create();
if (model.jdkDownloadUrl != null) {
progressIndicator.setText("Deploying custom jdk...");
WebAppUtils.deployCustomJdk(myWebApp, model.jdkDownloadUrl, model.webContainer, progressIndicator);
}
// update cache
if (model.isResourceGroupCreateNew) {
ResourceGroup rg = azure.resourceGroups().getByName(model.resourceGroupNameCreateNew);
if (rg == null) {
throw new AzureCmdException(String.format("azure.resourceGroups().getByName(%s) returned null"), model.resourceGroupNameCreateNew);
}
AzureModelController.addNewResourceGroup(model.subscriptionDetail, rg);
AzureModelController.addNewWebAppToJustCreatedResourceGroup(rg, myWebApp);
if (model.isAppServicePlanCreateNew) {
AzureModelController.addNewAppServicePlanToJustCreatedResourceGroup(rg, appServicePlan);
} else {
// add empty list
AzureModelController.addNewAppServicePlanToJustCreatedResourceGroup(rg, null);
}
} else {
ResourceGroup rg = model.resourceGroup;
AzureModelController.addNewWebAppToExistingResourceGroup(rg, myWebApp);
if (model.isAppServicePlanCreateNew) {
//AppServicePlan asp = azure.appServices().appServicePlans().getById(myWebApp.appServicePlanId());
AzureModelController.addNewAppServicePlanToExistingResourceGroup(rg, appServicePlan);
}
}
return myWebApp;
}
use of com.microsoft.azuretools.sdkmanage.AzureManager in project azure-tools-for-java by Microsoft.
the class ClusterOperationImpl method requestWithToken.
@NotNull
public <T> T requestWithToken(@NotNull String tenantId, @NotNull final RequestCallback<T> requestCallback) throws Throwable {
AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
// not signed in
if (azureManager == null) {
return null;
}
String accessToken = azureManager.getAccessToken(tenantId);
return requestCallback.execute(accessToken);
}
Aggregations