public override async Task RunAsync() { // Get function app var functionApp = await AzureHelper.GetFunctionApp(FunctionAppName, AccessToken, ManagementURL); // Get the GitIgnoreParser from the functionApp root var functionAppRoot = ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory); var ignoreParser = PublishHelper.GetIgnoreParser(functionAppRoot); // Get the WorkerRuntime var workerRuntime = WorkerRuntimeLanguageHelper.GetCurrentWorkerRuntimeLanguage(_secretsManager); // Check for any additional conditions or app settings that need to change // before starting any of the publish activity. var additionalAppSettings = await ValidateFunctionAppPublish(functionApp, workerRuntime); if (workerRuntime == WorkerRuntime.dotnet && !Csx && !NoBuild) { if (DotnetHelpers.CanDotnetBuild()) { var outputPath = Path.Combine("bin", "publish"); await DotnetHelpers.BuildDotnetProject(outputPath, DotnetCliParameters); Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, outputPath); } else if (StaticSettings.IsDebug) { ColoredConsole.WriteLine("Could not find a valid .csproj file. Skipping the build."); } } if (workerRuntime != WorkerRuntime.dotnet || Csx) { // Restore all valid extensions var installExtensionAction = new InstallExtensionAction(_secretsManager, false); await installExtensionAction.RunAsync(); } if (ListIncludedFiles) { InternalListIncludedFiles(ignoreParser); } else if (ListIgnoredFiles) { InternalListIgnoredFiles(ignoreParser); } else { if (PublishLocalSettingsOnly) { await PublishLocalAppSettings(functionApp, additionalAppSettings); } else { await PublishFunctionApp(functionApp, ignoreParser, additionalAppSettings); } } }
public override async Task RunAsync() { // Get function app var functionApp = await AzureHelper.GetFunctionApp(FunctionAppName, AccessToken); // Get the GitIgnoreParser from the functionApp root var functionAppRoot = ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory); var ignoreParser = PublishHelper.GetIgnoreParser(functionAppRoot); // Get the WorkerRuntime var workerRuntime = WorkerRuntimeLanguageHelper.GetCurrentWorkerRuntimeLanguage(_secretsManager); // Check for any additional conditions or app settings that need to change // before starting any of the publish activity. var additionalAppSettings = ValidateFunctionAppPublish(functionApp, workerRuntime); if (workerRuntime == WorkerRuntime.dotnet && !Csx && !NoBuild) { const string outputPath = "bin/publish"; await DotnetHelpers.BuildDotnetProject(outputPath, DotnetCliParameters); Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, outputPath); } if (ListIncludedFiles) { InternalListIncludedFiles(ignoreParser); } else if (ListIgnoredFiles) { InternalListIgnoredFiles(ignoreParser); } else { if (PublishLocalSettingsOnly) { await PublishLocalAppSettings(functionApp, additionalAppSettings); } else { await PublishFunctionApp(functionApp, ignoreParser, additionalAppSettings); } } }
/// <summary> /// Handler for Linux Consumption publish event /// </summary> /// <param name="functionAppRoot">Function App project path in local machine</param> /// <param name="functionApp">Function App in Azure</param> /// <param name="fileNameNoExtension">Name of the file to be uploaded</param> /// <returns>ShouldSyncTrigger value</returns> private async Task <bool> HandleLinuxConsumptionPublish(string functionAppRoot, Site functionApp, string fileNameNoExtension) { // Choose if the content need to use remote build BuildOption buildOption = PublishHelper.UpdateLinuxConsumptionBuildOption(PublishBuildOption); GitIgnoreParser ignoreParser = PublishHelper.GetIgnoreParser(functionAppRoot); // We update the buildOption, so we need to update the zipFileStream factory as well Func <Task <Stream> > zipFileStreamTask = () => ZipHelper.GetAppZipFile(functionAppRoot, BuildNativeDeps, buildOption, NoBuild, ignoreParser, AdditionalPackages, ignoreDotNetCheck: true); // Consumption Linux, try squashfs as a package format. if (GlobalCoreToolsSettings.CurrentWorkerRuntimeOrNone == WorkerRuntime.python && !NoBuild && (BuildNativeDeps || buildOption == BuildOption.Remote)) { if (BuildNativeDeps) { await PublishRunFromPackage(functionApp, await PythonHelpers.ZipToSquashfsStream(await zipFileStreamTask()), $"{fileNameNoExtension}.squashfs"); return(true); } // Remote build don't need sync trigger, container will be deallocated once the build is finished if (buildOption == BuildOption.Remote) { await RemoveFunctionAppAppSetting(functionApp, "WEBSITE_RUN_FROM_PACKAGE", "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", "WEBSITE_CONTENTSHARE"); Task <DeployStatus> pollConsumptionBuild(HttpClient client) => KuduLiteDeploymentHelpers.WaitForConsumptionServerSideBuild(client, functionApp, AccessToken, ManagementURL); var deployStatus = await PerformServerSideBuild(functionApp, zipFileStreamTask, pollConsumptionBuild); return(deployStatus == DeployStatus.Success); } } else { await PublishRunFromPackage(functionApp, await zipFileStreamTask(), $"{fileNameNoExtension}.zip"); return(true); } return(true); }
public override async Task RunAsync() { // Get function app var functionApp = await AzureHelper.GetFunctionApp(FunctionAppName, AccessToken, ManagementURL, Slot, Subscription); if (!functionApp.IsLinux && (PublishBuildOption == BuildOption.Container || PublishBuildOption == BuildOption.Remote)) { throw new CliException($"--build {PublishBuildOption} is not supported for Windows Function Apps."); } // Get the GitIgnoreParser from the functionApp root var functionAppRoot = ScriptHostHelpers.GetFunctionAppRootDirectory(Environment.CurrentDirectory); var ignoreParser = PublishHelper.GetIgnoreParser(functionAppRoot); // Get the WorkerRuntime var workerRuntime = GlobalCoreToolsSettings.CurrentWorkerRuntime; // Check for any additional conditions or app settings that need to change // before starting any of the publish activity. var additionalAppSettings = await ValidateFunctionAppPublish(functionApp, workerRuntime); // Update build option PublishBuildOption = PublishHelper.ResolveBuildOption(PublishBuildOption, workerRuntime, functionApp, BuildNativeDeps, NoBuild); if (workerRuntime == WorkerRuntime.dotnet && !Csx && !NoBuild && PublishBuildOption != BuildOption.Remote) { if (DotnetHelpers.CanDotnetBuild()) { var outputPath = Path.Combine("bin", "publish"); await DotnetHelpers.BuildDotnetProject(outputPath, DotnetCliParameters); Environment.CurrentDirectory = Path.Combine(Environment.CurrentDirectory, outputPath); } else if (StaticSettings.IsDebug) { ColoredConsole.WriteLine("Could not find a valid .csproj file. Skipping the build."); } } if (workerRuntime != WorkerRuntime.dotnet || Csx) { // Restore all valid extensions var installExtensionAction = new InstallExtensionAction(_secretsManager, false); await installExtensionAction.RunAsync(); } if (ListIncludedFiles) { InternalListIncludedFiles(ignoreParser); } else if (ListIgnoredFiles) { InternalListIgnoredFiles(ignoreParser); } else { if (PublishLocalSettingsOnly) { await PublishLocalAppSettings(functionApp, additionalAppSettings); } else { await PublishFunctionApp(functionApp, ignoreParser, additionalAppSettings); } } }