use of com.microsoft.azure.toolkit.lib.appservice.task.CreateOrUpdateFunctionAppTask in project azure-maven-plugins by microsoft.
the class DeployMojo method createOrUpdateResource.
protected IFunctionAppBase<?> createOrUpdateResource(final FunctionAppConfig config) {
IFunctionApp app = Azure.az(AzureAppService.class).functionApp(config.resourceGroup(), config.appName());
final boolean newFunctionApp = !app.exists();
AppServiceConfig defaultConfig = !newFunctionApp ? fromAppService(app, app.plan()) : buildDefaultConfig(config.subscriptionId(), config.resourceGroup(), config.appName());
mergeAppServiceConfig(config, defaultConfig);
if (!newFunctionApp && !config.disableAppInsights() && StringUtils.isEmpty(config.appInsightsKey())) {
// fill ai key from existing app settings
config.appInsightsKey(app.entity().getAppSettings().get(CreateOrUpdateFunctionAppTask.APPINSIGHTS_INSTRUMENTATION_KEY));
}
return new CreateOrUpdateFunctionAppTask(config).execute();
}
use of com.microsoft.azure.toolkit.lib.appservice.task.CreateOrUpdateFunctionAppTask in project azure-gradle-plugins by microsoft.
the class DeployHandler method createOrUpdateFunctionApp.
@Nonnull
private FunctionAppBase<?, ?, ?> createOrUpdateFunctionApp() throws AzureExecutionException {
final FunctionApp app = getFunctionApp();
final FunctionAppConfig functionConfig = (FunctionAppConfig) new FunctionAppConfig().disableAppInsights(ctx.isDisableAppInsights()).appInsightsKey(ctx.getAppInsightsKey()).appInsightsInstance(ctx.getAppInsightsInstance()).subscriptionId(ctx.getOrCreateAzureAppServiceClient().getSubscriptionId()).resourceGroup(ctx.getResourceGroup()).appName(ctx.getAppName()).servicePlanName(ctx.getAppServicePlanName()).servicePlanResourceGroup(ctx.getAppServicePlanResourceGroup()).deploymentSlotName(// gradle function plugin doesn't support deploy slot now
ctx.getDeploymentSlotName()).deploymentSlotConfigurationSource(ctx.getDeploymentSlotConfigurationSource()).pricingTier(getParsedPricingTier()).region(getParsedRegion()).runtime(getRuntimeConfig()).appSettings(ctx.getAppSettings());
final boolean createFunctionApp = Optional.ofNullable(app).map(function -> !function.exists()).orElse(true);
final AppServiceConfig defaultConfig = createFunctionApp ? buildDefaultConfig(functionConfig.subscriptionId(), functionConfig.resourceGroup(), functionConfig.appName()) : fromAppService(app, Objects.requireNonNull(app.getAppServicePlan()));
mergeAppServiceConfig(functionConfig, defaultConfig);
if (!createFunctionApp && !functionConfig.disableAppInsights() && StringUtils.isBlank(functionConfig.appInsightsKey())) {
// fill ai key from existing app settings
final String aiKey = Optional.ofNullable(app.getAppSettings()).map(map -> map.get(CreateOrUpdateFunctionAppTask.APPINSIGHTS_INSTRUMENTATION_KEY)).orElse(null);
functionConfig.appInsightsKey(aiKey);
}
validateArtifactCompileVersion(functionConfig.runtime());
return new CreateOrUpdateFunctionAppTask(functionConfig).execute();
}
Aggregations