Azure Functions Host
repository·dev·Indexed 24 days ago
https://github.com/azure/azure-functions-hostThe core runtime host for the Azure Functions service, built upon the Azure WebJobs SDK. It provides the underlying infrastructure to execute functions across multiple languages using various triggers and bindings. The repository includes documentation for running WebJobs.Script benchmarks, managing JSON schemas, integrating language worker protobufs via git subtrees, and building/publishing Site Extensions.
What's inside azure-functions-host
- The Azure Functions Host is the runtime host for the Azure Functions service. It is built upon the Azure WebJobs SDK to provide a hosting platform that supports multiple languages and a wide variety of triggers and bindings.
Locate and use Azure Functions JSON Schemas
devThe JSON schemas in this repository are copies of the official schemas published to the JSON Schema Store. These schemas are used by Azure Functions tooling, such as Visual Studio, to provide validation and IntelliSense for configuration files.
Important Maintenance Notes:
host.jsonschema: This schema is no longer maintained in this repository; it is now maintained in the Azure/Azure-Functions repository.- Making changes: If you need to update a schema, you must submit a Pull Request to the Schema Store Repository rather than this repository. Changes made here are merely copies.
Generate a Private Site Extension (PSE)
devPrivate Site Extensions (PSE) are not generated during the standard build process. To generate one, navigate to the publish output directory (
{repo_root}/out/pub/WebJobs.Script.SiteExtension/{config}_win) and run theNew-PrivateSiteExtension.ps1script.By default, it generates a zipped x64 PSE.
# Generates a zipped x64 PSE by default ./New-PrivateSiteExtension.ps1 # To generate x86 / 32bit: ./New-PrivateSiteExtension.ps1 -Bitness x86 # Can skip zipping the extension: ./New-PrivateSiteExtension.ps1 -NoZipCompress the Site Extension into a .zip package
devThere are two ways to produce a compressed (.zip) site extension:
- Via dotnet publish: Add the
-p:ZipAfterPublish=trueflag to your publish command. The resulting zip will be located at{repo_root}/out/pkg/{config}. - Via PowerShell script: If you have already published the unzipped files to
{repo_root}/out/pub/WebJobs.Script.SiteExtension/{config}_win, you can runCompress-SiteExtension.ps1. This method allows you to insert JIT trace files during the compression process.
# Produces the .zip site extension by default ./Compress-SiteExtension.ps1 # Produce the zip, inserting JIT trace files beforehand. ./Compress-SiteExtension.ps1 -JitTrace "path/to/file.jittrace", "path/to/file2.jittrace"- Via dotnet publish: Add the
Build and publish the Site Extension using dotnet CLI
devThe Site Extension can be built and published using MSBuild commands. You can perform these steps together in a single command or separately for more granular control.
Note: When building separately, you must set
PublishReadyToRun=true(this requirement is fixed in the .NET 9 SDK).# Together dotnet publish -c {config} # Separately dotnet restore -p:PublishReadyToRun=true dotnet build -c {config} --no-restore dotnet publish -c {config} --no-buildUpdate the Language Worker Protobuf subtree
devIf your language worker repository already has the protobuf repository embedded as a subtree, follow these steps to pull updates from a specific release tag:
- Add the
proto-fileremote and fetch it if not already present. - Fetch the specific release tag you want to update to (e.g.,
v1.1.0-protofile). - Merge the updates using the
-X subtreestrategy option to handle the subtree path correctly. Use--squashto keep the history clean and--allow-unrelated-historiesto permit the merge. - Commit and push the update.
git remote add proto-file https://github.com/azure/azure-functions-language-worker-protobuf.git git fetch proto-file git fetch proto-file refs/tags/<tag-name> git merge -X subtree=<path in language worker repo> --squash <tag-name> --allow-unrelated-histories --strategy-option theirs git commit -m "Updated subtree from https://github.com/azure/azure-functions-language-worker-protobuf. Tag: <tag-name>. Commit: <commit hash>" git push- Add the
Run WebJobs.Script Benchmarks
devTo execute the performance benchmarks for the WebJobs.Script components, use the
dotnet runcommand from the solution root. You can either use the interactive prompt to select specific benchmarks or pass a filter directly via the command line.Interactive Mode
Running the base command will present a list of discovered benchmarks. You can select them by entering their index number (e.g.,
0), their caption (e.g.,AuthUtilityBenchmarks), or multiple benchmarks separated by spaces (e.g.,1 2 3).Filtered Mode
To bypass the interactive prompt and run specific benchmarks immediately, use the
--filterflag with a glob pattern (e.g.,*BenchmarkName*).Add the Language Worker Protobuf repo as a subtree
devTo use the gRPC service definitions in an Azure Functions language worker repository, add this repository as a git subtree. This ensures the protobuf files are embedded directly in your worker's source tree.
Follow these steps from within your language worker repository:
- Add the protobuf repository as a remote named
proto-file. - Fetch the remote.
- Use
git read-treeto index the contents of a specific version branch into a chosen path in your repository. - Add that path to your
.gitignoreto prevent accidental commits of the raw subtree files. - Commit and push the changes.
git remote add proto-file https://github.com/azure/azure-functions-language-worker-protobuf.git git fetch proto-file git read-tree --prefix=<path in language worker repo> -u proto-file/<version branch> # Add <path in language worker repo> to .gitignore git commit -m "Added subtree from https://github.com/azure/azure-functions-language-worker-protobuf. Branch: <version branch>. Commit: <latest protobuf commit hash>" git push- Add the protobuf repository as a remote named
Generate Java code from FunctionRPC.proto
devFor Java workers, use the
protobuf-maven-plugin. Configure theprotoSourceRootin yourpom.xmlto point to the directory containing the.protofiles within the subtree.Configuration:
<protoSourceRoot>${basedir}/<path to this repo>/azure-functions-language-worker-protobuf/src/proto</protoSourceRoot><protoSourceRoot>${basedir}/<path to this repo>/azure-functions-language-worker-protobuf/src/proto</protoSourceRoot>Generate JavaScript and TypeScript code from FunctionRPC.proto
devUse the
protobufjsnpm package to generate runtime code from the protobuf definition. You can generate CommonJS JavaScript modules or static TypeScript definitions.Generate JavaScript (CommonJS): Use
pbjswith the-t json-moduleflag.Generate TypeScript: Use
pbjswith the-t static-moduleflag to create a static JS file, then usepbtsto generate the corresponding.d.tsdeclaration file.Generate Python code from FunctionRPC.proto
devTo build the Python implementation, install the package in editable mode with dev dependencies and run the setup build command.
python -m pip install -e .[dev] -U python setup.py buildGenerate C# code from FunctionRPC.proto
devTo generate C# classes and gRPC services from the protobuf definition, use
protoc.exewith thegrpc.toolsandgoogle.protobuf.toolsNuGet packages.Prerequisites:
- Set
NUGET_PATHto your local NuGet packages directory. - Set
versionNumberto the version of the tools you are using. - Ensure
GRPC_TOOLS_PATHandPROTOBUF_TOOLSare correctly pointed to the tool binaries within your NuGet cache.
set NUGET_PATH="%UserProfile%\.nuget\packages" set GRPC_TOOLS_PATH=%NUGET_PATH%\grpc.tools\<versionNumber>\tools\windows_x86 set PROTO_PATH=.\azure-functions-language-worker-protobuf\src\proto set PROTO=.\azure-functions-language-worker-protobuf\src\proto\FunctionRpc.proto set PROTOBUF_TOOLS=%NUGET_PATH%\google.protobuf.tools\<versionNumber>\tools set MSGDIR=.\Messages if exist %MSGDIR% rmdir /s /q %MSGDIR% mkdir %MSGDIR% set OUTDIR=%MSGDIR%\DotNet mkdir %OUTDIR% %GRPC_TOOLS_PATH%\protoc.exe %PROTO% --csharp_out %OUTDIR% --grpc_out=%OUTDIR% --plugin=protoc-gen-grpc=%GRPC_TOOLS_PATH%\grpc_csharp_plugin.exe --proto_path=%PROTO_PATH% --proto_path=%PROTOBUF_TOOLS%- Set