use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class WebAppRunState method executeSteps.
@Nullable
@Override
@AzureOperation(name = "webapp.deploy_artifact", params = { "this.webAppConfiguration.getWebAppName()" }, type = AzureOperation.Type.ACTION)
public IAppService executeSteps(@NotNull RunProcessHandler processHandler, @NotNull Operation operation) throws Exception {
File file = new File(getTargetPath());
if (!file.exists()) {
throw new FileNotFoundException(message("webapp.deploy.error.noTargetFile", file.getAbsolutePath()));
}
webAppConfiguration.setTargetName(file.getName());
final IWebAppBase deployTarget = getOrCreateDeployTargetFromAppSettingModel(processHandler);
updateApplicationSettings(deployTarget, processHandler);
AzureWebAppMvpModel.getInstance().deployArtifactsToWebApp(deployTarget, file, webAppSettingModel.isDeployToRoot(), processHandler);
return deployTarget;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AzureWebAppMvpModel method updateWebAppOnDocker.
/**
* Update container settings for existing Web App on Linux.
*
* @param webAppId id of Web App on Linux instance
* @param imageSetting new container settings
* @return instance of the updated Web App on Linux
*/
@AzureOperation(name = "docker|image.update", params = { "nameFromResourceId(webAppId)", "imageSetting.getImageNameWithTag()" }, type = AzureOperation.Type.SERVICE)
public IWebApp updateWebAppOnDocker(String webAppId, ImageSetting imageSetting) {
final IWebApp app = com.microsoft.azure.toolkit.lib.Azure.az(AzureAppService.class).webapp(webAppId);
// clearTags(app);
if (imageSetting instanceof PrivateRegistryImageSetting) {
final PrivateRegistryImageSetting pr = (PrivateRegistryImageSetting) imageSetting;
final DockerConfiguration dockerConfiguration = DockerConfiguration.builder().image(pr.getImageTagWithServerUrl()).registryUrl(pr.getServerUrl()).userName(pr.getUsername()).password(pr.getPassword()).startUpCommand(pr.getStartupFile()).build();
app.update().withDockerConfiguration(dockerConfiguration).commit();
}
// status-free restart.
app.restart();
return app;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AzureManagerBase method getSubscriptionsWithTenant.
@Override
@AzureOperation(name = "account|subscription.list.tenant|authorized", type = AzureOperation.Type.SERVICE)
public List<Pair<Subscription, Tenant>> getSubscriptionsWithTenant() {
final List<Pair<Subscription, Tenant>> subscriptions = new LinkedList<>();
final Azure.Authenticated authentication = authTenant(getCurrentTenantId());
// could be multi tenant - return all subscriptions for the current account
final List<Tenant> tenants = getTenants(authentication);
final List<String> failedTenantIds = new ArrayList<>();
for (final Tenant tenant : tenants) {
try {
final Azure.Authenticated tenantAuthentication = authTenant(tenant.tenantId());
final List<Subscription> tenantSubscriptions = getSubscriptions(tenantAuthentication);
for (final Subscription subscription : tenantSubscriptions) {
subscriptions.add(new Pair<>(subscription, tenant));
}
} catch (final Exception e) {
// just skip for cases user failing to get subscriptions of tenants he/she has no permission to get access token.
LOGGER.log(Level.WARNING, e.getMessage(), e);
failedTenantIds.add(tenant.tenantId());
}
}
if (!failedTenantIds.isEmpty()) {
final INotification nw = CommonSettings.getUiFactory().getNotificationWindow();
nw.deliver("Lack permission for some tenants", "You don't have permission on the tenant(s): " + StringUtils.join(failedTenantIds, ","));
}
return subscriptions;
}
use of com.microsoft.azure.toolkit.lib.common.operation.AzureOperation in project azure-tools-for-java by Microsoft.
the class AzureManagerBase method authTenant.
@AzureOperation(name = "account|tenant.auth", params = { "tenantId" }, type = AzureOperation.Type.TASK)
protected Azure.Authenticated authTenant(String tenantId) {
final AzureTokenCredentials credentials = getCredentials(tenantId);
final Azure.Configurable configurable = Azure.configure().withInterceptor(new TelemetryInterceptor()).withUserAgent(CommonSettings.USER_AGENT);
Optional.ofNullable(createProxyFromConfig()).ifPresent(proxy -> {
configurable.withProxy(proxy);
Optional.ofNullable(createProxyAuthenticatorFromConfig()).ifPresent(configurable::withProxyAuthenticator);
});
return configurable.authenticate(credentials);
}
Aggregations