in src/Cli/func/Actions/AzureActions/PublishFunctionAppAction.cs [553:654]
private async Task PublishFunctionApp(Site functionApp, GitIgnoreParser ignoreParser, IDictionary<string, string> additionalAppSettings)
{
ColoredConsole.WriteLine("Getting site publishing info...");
var functionAppRoot = ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory);
// For dedicated linux apps, we do not support run from package right now
var isFunctionAppDedicatedLinux = functionApp.IsLinux && !functionApp.IsDynamic && !functionApp.IsElasticPremium && !functionApp.IsFlex;
if (GlobalCoreToolsSettings.CurrentWorkerRuntime == WorkerRuntime.Python && !functionApp.IsLinux)
{
throw new CliException("Publishing Python functions is only supported for Linux FunctionApps");
}
// Recommend Linux scm users to use --build remote instead of --build-native-deps
if (BuildNativeDeps && functionApp.IsLinux && !string.IsNullOrEmpty(functionApp.ScmUri))
{
ColoredConsole.WriteLine(WarningColor("Recommend using '--build remote' to resolve project dependencies remotely on Azure"));
}
bool useGoZip = EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.UseGoZip);
TelemetryHelpers.AddCommandEventToDictionary(TelemetryCommandEvents, "UseGoZip", useGoZip.ToString());
ColoredConsole.WriteLine(GetLogMessage("Starting the function app deployment..."));
Func<Task<Stream>> zipStreamFactory = () => ZipHelper.GetAppZipFile(functionAppRoot, BuildNativeDeps, PublishBuildOption, NoBuild, ignoreParser, AdditionalPackages, ignoreDotNetCheck: true);
bool shouldSyncTriggers = true;
bool shouldDeferPublishZipDeploy = false;
if (functionApp.IsKubeApp)
{
shouldSyncTriggers = false;
shouldDeferPublishZipDeploy = true;
}
else if (functionApp.IsLinux && functionApp.IsDynamic)
{
// Consumption Linux
shouldSyncTriggers = await HandleLinuxConsumptionPublish(functionApp, zipStreamFactory);
}
else if (functionApp.IsFlex)
{
// Flex
shouldSyncTriggers = await HandleFlexConsumptionPublish(functionApp, zipStreamFactory);
}
else if (functionApp.IsLinux && functionApp.IsElasticPremium)
{
// Elastic Premium Linux
shouldSyncTriggers = await HandleElasticPremiumLinuxPublish(functionApp, zipStreamFactory);
}
else if (isFunctionAppDedicatedLinux)
{
// Dedicated Linux
shouldSyncTriggers = false;
await HandleLinuxDedicatedPublish(functionApp, zipStreamFactory);
}
else if (!functionApp.IsLinux && PublishBuildOption == BuildOption.Remote)
{
await HandleWindowsRemoteBuildPublish(functionApp, zipStreamFactory);
}
else if (RunFromPackageDeploy)
{
// Windows default
await PublishRunFromPackageLocal(functionApp, zipStreamFactory);
}
else
{
// ZipDeploy takes care of the SyncTriggers operation so we don't
// need to perform one
shouldSyncTriggers = false;
// "--no-zip"
await PublishZipDeploy(functionApp, zipStreamFactory);
}
if (PublishLocalSettings)
{
await PublishLocalAppSettings(functionApp, additionalAppSettings);
}
else if (additionalAppSettings.Any())
{
await PublishAppSettings(functionApp, new Dictionary<string, string>(), additionalAppSettings);
}
if (shouldDeferPublishZipDeploy)
{
await PublishZipDeploy(functionApp, zipStreamFactory);
}
if (shouldSyncTriggers && !functionApp.IsFlex)
{
await Task.Delay(TimeSpan.FromSeconds(5));
await SyncTriggers(functionApp);
}
// Linux Elastic Premium functions take longer to deploy. So do Linux Dedicated Function Apps with remote build
// Right now, we cannot guarantee that functions info will be most up to date.
// So, we only show the info, if Function App is not Linux Elastic Premium
// or a Linux Dedicated Function App with remote build
if (!(functionApp.IsLinux && functionApp.IsElasticPremium)
&& !(isFunctionAppDedicatedLinux && PublishBuildOption == BuildOption.Remote))
{
await AzureHelper.PrintFunctionsInfo(functionApp, AccessToken, ManagementURL, showKeys: ShowKeys);
}
}