use of com.microsoft.azure.toolkit.lib.appservice.function.FunctionApp 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