use of com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp in project azure-tools-for-java by Microsoft.
the class FunctionAppService method createFunctionApp.
public IFunctionApp createFunctionApp(final FunctionAppConfig config) {
AzureTelemetry.getActionContext().setProperty(CREATE_NEW_FUNCTION_APP, String.valueOf(true));
final ResourceGroup resourceGroup = getOrCreateResourceGroup(config);
final IAppServicePlan appServicePlan = getOrCreateAppServicePlan(config);
AzureMessager.getMessager().info(String.format(CREATE_FUNCTION_APP, config.getName()));
final Map<String, String> appSettings = getAppSettings(config);
// get/create ai instances only if user didn't specify ai connection string in app settings
AzureTelemetry.getActionContext().setProperty(DISABLE_APP_INSIGHTS, String.valueOf(config.getMonitorConfig().getApplicationInsightsConfig() == null));
bindApplicationInsights(appSettings, config);
final IFunctionApp result = Azure.az(AzureAppService.class).subscription(config.getSubscription()).functionApp(resourceGroup.getName(), config.getName()).create().withName(config.getName()).withResourceGroup(resourceGroup.getName()).withPlan(appServicePlan.id()).withRuntime(config.getRuntime()).withAppSettings(appSettings).withDiagnosticConfig(config.getMonitorConfig().getDiagnosticConfig()).commit();
AzureMessager.getMessager().info(String.format(CREATE_FUNCTION_APP_DONE, result.name()));
return result;
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp in project azure-tools-for-java by Microsoft.
the class CreateFunctionAppAction method createFunctionApp.
@AzureOperation(name = "function.create_detail", params = { "config.getName()" }, type = AzureOperation.Type.ACTION)
private Single<IFunctionApp> createFunctionApp(final FunctionAppConfig config) {
final AzureString title = title("function.create_detail", config.getName());
final IntellijAzureMessager actionMessenger = new IntellijAzureMessager() {
@Override
public boolean show(IAzureMessage raw) {
if (raw.getType() != IAzureMessage.Type.INFO) {
return super.show(raw);
}
return false;
}
};
final AzureTask<IFunctionApp> task = new AzureTask<>(null, title, false, () -> {
final Operation operation = TelemetryManager.createOperation(TelemetryConstants.FUNCTION, TelemetryConstants.CREATE_FUNCTION_APP);
operation.trackProperties(config.getTelemetryProperties());
try {
AzureMessager.getContext().setMessager(actionMessenger);
final ProgressIndicator indicator = ProgressManager.getInstance().getProgressIndicator();
indicator.setIndeterminate(true);
return functionAppService.createFunctionApp(config);
} finally {
operation.trackProperties(AzureTelemetry.getActionContext().getProperties());
operation.complete();
}
});
return AzureTaskManager.getInstance().runInModalAsObservable(task).toSingle().doOnSuccess(app -> {
AzureMessager.getMessager().success(message("function.create.success.message", app.name()), message("function.create.success.title"));
this.refreshAzureExplorer(app);
});
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp in project azure-tools-for-java by Microsoft.
the class DeployFunctionAppAction method getRunConfigurationSettings.
private RunnerAndConfigurationSettings getRunConfigurationSettings(RunManagerEx manager) {
final ConfigurationFactory factory = new FunctionDeploymentConfigurationFactory(functionType);
final String runConfigurationName = String.format("%s: %s:%s", factory.getName(), project.getName(), functionNode.getName());
RunnerAndConfigurationSettings settings = manager.findConfigurationByName(runConfigurationName);
if (settings == null) {
settings = manager.createConfiguration(runConfigurationName, factory);
}
final RunConfiguration runConfiguration = settings.getConfiguration();
if (runConfiguration instanceof FunctionDeployConfiguration) {
final IFunctionApp functionApp = Azure.az(AzureAppService.class).functionApp(functionNode.getId());
final FunctionAppConfig config = FunctionAppService.getInstance().getFunctionAppConfigFromExistingFunction(functionApp);
((FunctionDeployConfiguration) runConfiguration).saveConfig(config);
}
return settings;
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp in project azure-tools-for-java by Microsoft.
the class FunctionDeploymentState method createFunctionApp.
private IFunctionApp createFunctionApp(@NotNull RunProcessHandler processHandler) {
IFunctionApp functionApp = Azure.az(AzureAppService.class).subscription(functionDeployConfiguration.getSubscriptionId()).functionApp(functionDeployConfiguration.getConfig().getResourceGroup().getName(), functionDeployConfiguration.getAppName());
if (functionApp.exists()) {
return functionApp;
}
processHandler.setText(message("function.create.hint.creating", functionDeployConfiguration.getAppName()));
// Load app settings from security storage
final FunctionAppConfig config = deployModel.getFunctionAppConfig();
config.setAppSettings(FunctionUtils.loadAppSettingsFromSecurityStorage(functionDeployConfiguration.getAppSettingsKey()));
// create function app
functionApp = FunctionAppService.getInstance().createFunctionApp(config);
// update run configuration
functionDeployConfiguration.setFunctionId(functionApp.id());
// Notify explorer refresh
AzureUIRefreshCore.execute(new AzureUIRefreshEvent(AzureUIRefreshEvent.EventType.REFRESH, functionApp));
processHandler.setText(message("function.create.hint.created", functionDeployConfiguration.getAppName()));
return functionApp;
}
use of com.microsoft.azure.toolkit.lib.appservice.service.IFunctionApp in project azure-tools-for-java by Microsoft.
the class FunctionAppPropertyView method createPresenter.
@Override
protected WebAppBasePropertyViewPresenter createPresenter() {
return new WebAppBasePropertyViewPresenter() {
@Override
protected IFunctionApp getWebAppBase(String subscriptionId, String functionAppId, String name) {
return Azure.az(AzureAppService.class).subscription(subscriptionId).functionApp(functionAppId);
}
@Override
protected void updateAppSettings(String subscriptionId, String functionAppId, String name, Map toUpdate, Set toRemove) {
final IFunctionApp functionApp = getWebAppBase(subscriptionId, functionAppId, name);
final IAppServiceUpdater appServiceUpdater = functionApp.update();
appServiceUpdater.withAppSettings(toUpdate);
toRemove.forEach(key -> appServiceUpdater.withoutAppSettings((String) key));
appServiceUpdater.commit();
}
};
}
Aggregations