Skip to content

Commit

Permalink
Linux support for FunctionsNetHost (#1704)
Browse files Browse the repository at this point in the history
* FunctionsNetHost in managed code (#1551)

First iteration of Azure Functions Custom .NET Host(Validated in Windows)

* Adding support for linux cold start (#1594)

* Adding support for linux cold start.

* Using native "get_hostfxr_path" method from "nethost". Removed PathResolver code (which was our version to do the same thing)

* Update build YAML to copy all  files instead of just .exe.

* Linted yaml file. fixed the copy step to copy only needed dependencies

* YAML

* Get the NativeApplication instance from pointer and call the methods instead of static method call.

* Revert "Get the NativeApplication instance from pointer and call the methods instead of static method call."

This reverts commit 2f54a1c.

* Using NET8 Preview4.

* NET6 support on Debian

* Version bump for DotNetIsolatedNativeHost package

* Add net6.0;net7.0; to TargetFrameworks.

* Removing the shim for Windows.

* Rebase on main + used csproj from origin main. Updated dotnetworker.csprok to include net6.0;net7.0;

* Removed preivew tag(VersionSuffix) for now. Will add as needed when ready to release the packages.

* Nit fixes to address PR feedback(indentation, copyright notice)

* Added accidently deleted using statement block

* Updating release notes.

* Added a global.json for the FunctionsNetHost src directory to use .NET8 since our root level one uses 7.0. We use .NET AOT compiler to publish the FunctionsNetHost.

* Fixed the version to 8.0.100-preview

* Added "includePreviewVersions: true" to "Install current .NET SDK" build step.

* Switching version to 8.0.100-preview.6 and "rollForward" value to "latestMinor" in FunctionsNetHost/src/global.json

* Specifically set 7.0.306 in Install current .NET SDK step

* Add a new UseDotnet task to install .net8 preview 6 in install-dotnet.yml

* set includePreviewVersions true for new step

* usesGlobalJson false for new UseDotnet task

* use specific version 8.0.100-preview.6.23330.14
  • Loading branch information
kshyju authored Jul 26, 2023
1 parent 2ebe177 commit 2d16152
Show file tree
Hide file tree
Showing 56 changed files with 1,172 additions and 1,451 deletions.
162 changes: 125 additions & 37 deletions host/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
variables:
- name: VCPKG_BINARY_SOURCES
value: "clear;nuget,https://azfunc.pkgs.visualstudio.com/e6a70c92-4128-439f-8012-382fe78d6396/_packaging/FunctionsNetHostBinaryCache/nuget/v3/index.json,readwrite"
- name: VCPKG_USE_NUGET_CACHE
value: 1

trigger:
branches:
include:
- main
- release/*
- feature/*
paths:
include:
- host/src/
Expand All @@ -17,38 +12,131 @@ pr:
include:
- main
- release/*
- feature/*
paths:
include:
- host/src/
stages:
- stage: BuildAndPublish
displayName: "Dotnet Publish(W+L)"
jobs:
- job: BuildAndPublishLinux
displayName: "Publish on Linux"
pool:
vmImage: "ubuntu-20.04"
steps:
- task: UseDotNet@2
inputs:
version: "8.x"
includePreviewVersions: true

- script: |
sudo apt-get install clang zlib1g-dev
- task: DotnetCoreCLI@2
displayName: "Dotnet Publish"
inputs:
command: "publish"
publishWebProjects: false
zipAfterPublish: false
arguments: "-c Release -r linux-x64 -o $(Build.ArtifactStagingDirectory)/output/linux"
workingDirectory: $(Build.SourcesDirectory)/host/src/FunctionsNetHost

- task: CopyFiles@2
displayName: "Copy needed files"
inputs:
SourceFolder: "$(Build.ArtifactStagingDirectory)/output/linux"
# Publish output will include many other files. We only need the FunctionsNetHost & libnethost.so
Contents: |
FunctionsNetHost
libnethost.so
TargetFolder: "$(Build.ArtifactStagingDirectory)/output/linux_filtered"

- task: PublishPipelineArtifact@1
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/output/linux_filtered"
artifact: "linux_publish_output"

- job: BuildAndPublishWindows
displayName: "Publish on Windows"
pool:
vmImage: "windows-latest"
steps:
- task: UseDotNet@2
inputs:
version: "8.x"
includePreviewVersions: true

- task: DotnetCoreCLI@2
displayName: "Dotnet Publish"
inputs:
command: "publish"
publishWebProjects: false
zipAfterPublish: false
arguments: "-c Release -r win-x64 -o $(Build.ArtifactStagingDirectory)/output/windows"
workingDirectory: $(Build.SourcesDirectory)/host/src/FunctionsNetHost

- task: CopyFiles@2
displayName: "Copy needed files"
inputs:
SourceFolder: "$(Build.ArtifactStagingDirectory)/output/windows"
# Publish output will include many other files. We only need FunctionsNetHost.exe & nethost.dll
Contents: |
FunctionsNetHost.exe
nethost.dll
TargetFolder: "$(Build.ArtifactStagingDirectory)/output/windows_filtered"

- task: PublishPipelineArtifact@1
inputs:
targetPath: "$(Build.ArtifactStagingDirectory)/output/windows_filtered"
artifact: "windows_publish_output"

- stage: ConsolidateArtifacts
displayName: "Nuget Publish"
dependsOn: BuildAndPublish
jobs:
- job: ConsolidateArtifacts
displayName: "Consolidate Artifacts"
pool:
vmImage: "windows-latest"
steps:
- task: UseDotNet@2
inputs:
version: "7.x"

- task: DownloadPipelineArtifact@2
displayName: "Download Artifacts from Linux build"
inputs:
artifactName: "linux_publish_output"
path: "$(Build.ArtifactStagingDirectory)/linux_output"

- task: DownloadPipelineArtifact@2
displayName: "Download Artifacts from Windows build"
inputs:
artifactName: "windows_publish_output"
path: "$(Build.ArtifactStagingDirectory)/windows_output"

- task: CopyFiles@2
displayName: "Copy files from linux artifacts to dist dir"
inputs:
SourceFolder: "$(Build.ArtifactStagingDirectory)/linux_output"
TargetFolder: "$(Build.SourcesDirectory)/host/dist/linux"

- task: CopyFiles@2
displayName: "Copy files from Windows artifacts to dist dir"
inputs:
SourceFolder: "$(Build.ArtifactStagingDirectory)/windows_output"
TargetFolder: "$(Build.SourcesDirectory)/host/dist/windows"

- task: NuGetCommand@2
displayName: "Nuget pack"
inputs:
command: "pack"
packagesToPack: "$(Build.SourcesDirectory)/host/tools/build/Microsoft.Azure.Functions.DotnetIsolatedNativeHost.nuspec"
versioningScheme: "off"
packDestination: "$(Build.ArtifactStagingDirectory)/host/dist/nuget"
basePath: "$(Build.SourcesDirectory)/host/tools/build"

pool:
vmImage: windows-latest

steps:
# Remember to add this task to allow vcpkg to upload archives via NuGet
- task: NuGetAuthenticate@1

# Run Cmake and output goes to /build dir.
- task: CMake@1
displayName: "CMake generation"
inputs:
cmakeArgs: "-S $(Build.SourcesDirectory)/host/src -B $(Build.SourcesDirectory)/host/build/win-x64"

# Run Cmake --build which produces the native binaries.
- task: CMake@1
displayName: "CMake build"
inputs:
cmakeArgs: "--build $(Build.SourcesDirectory)/host/build/win-x64 --config Release"

- task: NuGetCommand@2
displayName: "Nuget pack"
inputs:
command: "pack"
packagesToPack: "$(Build.SourcesDirectory)/host/tools/build/Microsoft.Azure.Functions.DotnetIsolatedNativeHost.nuspec"
versioningScheme: "off"
packDestination: "$(Build.ArtifactStagingDirectory)/host/build/nuget"
basePath: "$(Build.SourcesDirectory)/host/tools/build"

# Publish artifacts.
- publish: $(Build.ArtifactStagingDirectory)/host/build/nuget
artifact: drop
# Publish artifacts.
- publish: $(Build.ArtifactStagingDirectory)/host/dist/nuget
artifact: drop
2 changes: 0 additions & 2 deletions host/src/.clang-format

This file was deleted.

28 changes: 0 additions & 28 deletions host/src/CMakeLists.txt

This file was deleted.

64 changes: 0 additions & 64 deletions host/src/CMakePresets.json

This file was deleted.

25 changes: 25 additions & 0 deletions host/src/FunctionsNetHost.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.33627.172
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FunctionsNetHost", "FunctionsNetHost\FunctionsNetHost.csproj", "{6C05D0AC-F6AC-45FB-8A73-A3F44DF131BC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6C05D0AC-F6AC-45FB-8A73-A3F44DF131BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C05D0AC-F6AC-45FB-8A73-A3F44DF131BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C05D0AC-F6AC-45FB-8A73-A3F44DF131BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C05D0AC-F6AC-45FB-8A73-A3F44DF131BC}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {32F98336-4B56-47A5-806E-0D1CC5F9F48B}
EndGlobalSection
EndGlobal
Loading

0 comments on commit 2d16152

Please sign in to comment.