Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating package zipping #4212

Merged
merged 15 commits into from
Feb 10, 2025
11 changes: 9 additions & 2 deletions Azure.Functions.Cli.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
# Visual Studio Version 17
VisualStudioVersion = 17.12.35506.116 d17.12
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5F51C958-39C0-4E0C-9165-71D0BCE647BC}"
EndProject
Expand All @@ -11,6 +11,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Functions.Cli", "src\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Azure.Functions.Cli.Tests", "test\Azure.Functions.Cli.Tests\Azure.Functions.Cli.Tests.csproj", "{EAEA6EDB-A301-4A50-86D8-91859DABE30E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ZippedExe", "test\ZippedExe\ZippedExe.csproj", "{2CD45039-0ABD-4082-87D0-52BB5D467B50}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -25,13 +27,18 @@ Global
{EAEA6EDB-A301-4A50-86D8-91859DABE30E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EAEA6EDB-A301-4A50-86D8-91859DABE30E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EAEA6EDB-A301-4A50-86D8-91859DABE30E}.Release|Any CPU.Build.0 = Release|Any CPU
{2CD45039-0ABD-4082-87D0-52BB5D467B50}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2CD45039-0ABD-4082-87D0-52BB5D467B50}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2CD45039-0ABD-4082-87D0-52BB5D467B50}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2CD45039-0ABD-4082-87D0-52BB5D467B50}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{6608738C-3BDB-47F5-BC62-66A8BDF9D884} = {5F51C958-39C0-4E0C-9165-71D0BCE647BC}
{EAEA6EDB-A301-4A50-86D8-91859DABE30E} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
{2CD45039-0ABD-4082-87D0-52BB5D467B50} = {6EE1D011-2334-44F2-9D41-608B969DAE6D}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {FA1E01D6-A57B-4061-A333-EDC511D283C0}
Expand Down
3 changes: 1 addition & 2 deletions build/Program.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System.IO;
using System.Linq;
using System.Linq;
using System.Net;
using static Build.BuildSteps;

Expand Down
29 changes: 28 additions & 1 deletion eng/ci/templates/public/jobs/build-test-public.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,31 @@ jobs:
testResultsFormat: 'VSTest'
testResultsFiles: '**/*.trx'
failTaskOnFailedTests: true
condition: succeededOrFailed()
condition: succeededOrFailed()
templateContext:
outputs:
- output: pipelineArtifact
path: 'test/Azure.Functions.Cli.Tests/bin/Debug/net8.0/ZippedOnWindows.zip'
artifact: ZippedOnWindows

- job: Test_Linux
timeoutInMinutes: "180"
pool:
name: 1es-pool-azfunc-public
image: '1es-ubuntu-22.04'
os: 'linux'
steps:
- download: current
displayName: 'Download test zip'
artifact: ZippedOnWindows
- script: |
sudo apt-get update
sudo apt-get -y install fuse-zip
displayName: 'Install fuse-zip'
- task: DotNetCoreCLI@2
inputs:
command: 'test'
projects: '**/Azure.Functions.Cli.Tests.csproj'
arguments: '--filter CreateZip_Succeeds'
displayName: 'Run zip test'
dependsOn: Default
1 change: 0 additions & 1 deletion skipPackagesCve.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"packages": [
"DotNetZip"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public override async Task RunAsync()
var targetFramework = await DotnetHelpers.DetermineTargetFramework(Path.GetDirectoryName(projectFilePath));

var majorDotnetVersion = StacksApiHelper.GetMajorDotnetVersionFromDotnetVersionInProject(targetFramework);

if (majorDotnetVersion != null)
{
// Get Stacks
Expand All @@ -179,8 +179,8 @@ public override async Task RunAsync()
ShowEolMessage(stacks, runtimeSettings, majorDotnetVersion.Value);

// This is for future proofing with stacks API for future dotnet versions.
if (runtimeSettings != null &&
(runtimeSettings.IsDeprecated == null || runtimeSettings.IsDeprecated == false) &&
if (runtimeSettings != null &&
(runtimeSettings.IsDeprecated == null || runtimeSettings.IsDeprecated == false) &&
(runtimeSettings.IsDeprecatedForRuntime == null || runtimeSettings.IsDeprecatedForRuntime == false))
{
_requiredNetFrameworkVersion = $"{majorDotnetVersion}.0";
Expand Down Expand Up @@ -275,12 +275,12 @@ private async Task<IDictionary<string, string>> ValidateFunctionAppPublish(Site
workerRuntimeStr = functionApp.FunctionAppConfig.runtime.name;
}

if (workerRuntime == WorkerRuntime.None)
{
if (workerRuntime == WorkerRuntime.None)
{
throw new CliException($"Worker runtime is not set. Please set a valid runtime using {Constants.FunctionsWorkerRuntime}");
}

if ((functionApp.IsFlex && !string.IsNullOrEmpty(workerRuntimeStr) ||
if ((functionApp.IsFlex && !string.IsNullOrEmpty(workerRuntimeStr) ||
(!functionApp.IsFlex && functionApp.AzureAppSettings.TryGetValue(Constants.FunctionsWorkerRuntime, out workerRuntimeStr))))
{
var resolution = $"You can pass --force to update your Azure app with '{workerRuntime}' as a '{Constants.FunctionsWorkerRuntime}'";
Expand Down Expand Up @@ -350,7 +350,7 @@ private async Task<IDictionary<string, string>> ValidateFunctionAppPublish(Site
(functionApp.IsFlex && !PythonHelpers.IsFlexPythonRuntimeVersionMatched(functionApp.FunctionAppConfig?.runtime?.name, functionApp.FunctionAppConfig?.runtime?.version, localVersion.Major, localVersion.Minor)))
{
ColoredConsole.WriteLine(WarningColor($"Local python version '{localVersion.Version}' is different from the version expected for your deployed Function App." +
$" This may result in 'ModuleNotFound' errors in Azure Functions. Please create a Python Function App for version {localVersion.Major}.{localVersion.Minor} or change the virtual environment on your local machine to match '{(functionApp.IsFlex? functionApp.FunctionAppConfig.runtime.version: functionApp.LinuxFxVersion)}'."));
$" This may result in 'ModuleNotFound' errors in Azure Functions. Please create a Python Function App for version {localVersion.Major}.{localVersion.Minor} or change the virtual environment on your local machine to match '{(functionApp.IsFlex ? functionApp.FunctionAppConfig.runtime.version : functionApp.LinuxFxVersion)}'."));
}
}

Expand Down Expand Up @@ -559,6 +559,9 @@ private async Task PublishFunctionApp(Site functionApp, GitIgnoreParser ignorePa
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);
Expand Down
6 changes: 4 additions & 2 deletions src/Azure.Functions.Cli/Actions/LocalActions/PackAction.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -9,7 +8,6 @@
using Colors.Net;
using Fclp;
using Microsoft.Azure.WebJobs.Script;
using static Colors.Net.StringStaticMethods;
using static Azure.Functions.Cli.Common.OutputTheme;

namespace Azure.Functions.Cli.Actions.LocalActions
Expand Down Expand Up @@ -104,6 +102,10 @@ public override async Task RunAsync()
// Restore all valid extensions
var installExtensionAction = new InstallExtensionAction(_secretsManager, false);
await installExtensionAction.RunAsync();

bool useGoZip = EnvironmentHelper.GetEnvironmentVariableAsBool(Constants.UseGoZip);
TelemetryHelpers.AddCommandEventToDictionary(TelemetryCommandEvents, "UseGoZip", useGoZip.ToString());

var stream = await ZipHelper.GetAppZipFile(functionAppRoot, BuildNativeDeps, noBuild: false, buildOption: BuildOption.Default, additionalPackages: AdditionalPackages);

if (Squashfs)
Expand Down
4 changes: 1 addition & 3 deletions src/Azure.Functions.Cli/Azure.Functions.Cli.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,6 @@
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.7.0" />
<PackageReference Include="Colors.Net" Version="1.1.0" />
<PackageReference Include="AccentedCommandLineParser" Version="2.0.0" />
<PackageReference Include="DotNetZip" Version="1.16.0" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.22.0" />
<PackageReference Include="Microsoft.AspNetCore.DataProtection" Version="2.2.0" />
<PackageReference Include="Microsoft.Azure.DurableTask.AzureStorage.Internal" Version="1.4.0" />
Expand All @@ -284,8 +283,7 @@
<PackageReference Include="Microsoft.Identity.Client" Version="4.61.3" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NuGet.Packaging" Version="5.11.6" />
<PackageReference Include="System.Formats.Asn1" Version="6.0.1" />
<PackageReference Include="System.Text.Json" Version="8.0.5" />
<PackageReference Include="System.Formats.Asn1" Version="6.0.1" />
<PackageReference Include="WindowsAzure.Storage" Version="9.3.1" />
<PackageReference Include="YamlDotNet" Version="6.0.0" />

Expand Down
3 changes: 2 additions & 1 deletion src/Azure.Functions.Cli/Common/Constants.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Azure.Functions.Cli.Helpers;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Reflection;
using Azure.Functions.Cli.Helpers;

namespace Azure.Functions.Cli.Common
{
Expand Down Expand Up @@ -63,6 +63,7 @@ internal static class Constants
public const string UserSecretsIdElementName = "UserSecretsId";
public const string TargetFrameworkElementName = "TargetFramework";
public const string DisplayLogo = "FUNCTIONS_CORE_TOOLS_DISPLAY_LOGO";
public const string UseGoZip = "FUNCTIONS_CORE_TOOLS_USE_GOZIP";
public const string AspNetCoreSupressStatusMessages = "ASPNETCORE_SUPPRESSSTATUSMESSAGES";
public const string SequentialJobHostRestart = "AzureFunctionsJobHost__SequentialRestart";
public const long DefaultMaxRequestBodySize = 104857600;
Expand Down
Loading
Loading