├── .gitignore ├── CODEOWNERS ├── LICENSE ├── README.md ├── SECURITY.md └── src └── proto ├── FunctionRpc.proto ├── identity └── ClaimsIdentityRpc.proto └── shared └── NullableTypes.proto /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/about-codeowners/ 2 | # for more info about CODEOWNERS file 3 | # 4 | # It uses the same pattern rule for gitignore file 5 | # https://git-scm.com/docs/gitignore#_pattern_format 6 | 7 | 8 | 9 | # AZURE FUNCTIONS TEAM 10 | # For all file changes, github would automatically 11 | # include the following people in the PRs. 12 | # Language owners should get notified of any new changes to the proto file. 13 | 14 | src/proto/FunctionRpc.proto @vrdmr @gavin-aguiar @YunchuWang @surgupta-msft @satvu @ejizba @alrod @anatolib @kaibocai @shreyas-gopalakrishna @amamounelsayed @Francisco-Gamino 15 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) Microsoft Corporation. All rights reserved. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Azure Functions Language Worker Protobuf 2 | 3 | This repository contains the protobuf definition file which defines the gRPC service which is used between the [Azure Functions Host](https://github.com/Azure/azure-functions-host) and the Azure Functions language workers. This repo is shared across many repos in many languages (for each worker) by using git commands. 4 | 5 | To use this repo in Azure Functions language workers, follow steps below to add this repo as a subtree (*Adding This Repo*). If this repo is already embedded in a language worker repo, follow the steps to update the consumed file (*Pulling Updates*). 6 | 7 | Learn more about Azure Function's projects on the [meta](https://github.com/azure/azure-functions) repo. 8 | 9 | ## Adding This Repo 10 | 11 | From within the Azure Functions language worker repo: 12 | 1. Define remote branch for cleaner git commands 13 | - `git remote add proto-file https://github.com/azure/azure-functions-language-worker-protobuf.git` 14 | - `git fetch proto-file` 15 | 2. Index contents of azure-functions-worker-protobuf to language worker repo 16 | - `git read-tree --prefix= -u proto-file/` 17 | 3. Add new path in language worker repo to .gitignore file 18 | - In .gitignore, add path in language worker repo 19 | 4. Finalize with commit 20 | - `git commit -m "Added subtree from https://github.com/azure/azure-functions-language-worker-protobuf. Branch: . Commit: "` 21 | - `git push` 22 | 23 | ## Pulling Updates 24 | 25 | From within the Azure Functions language worker repo: 26 | 1. Define remote branch for cleaner git commands 27 | - `git remote add proto-file https://github.com/azure/azure-functions-language-worker-protobuf.git` 28 | - `git fetch proto-file` 29 | 2. Pull a specific release tag 30 | - `git fetch proto-file refs/tags/` 31 | - Example: `git fetch proto-file refs/tags/v1.1.0-protofile` 32 | 3. Merge updates 33 | - Merge with an explicit path to subtree: `git merge -X subtree= --squash --allow-unrelated-histories --strategy-option theirs` 34 | - Example: `git merge -X subtree=src/WebJobs.Script.Grpc/azure-functions-language-worker-protobuf --squash v1.1.0-protofile --allow-unrelated-histories --strategy-option theirs` 35 | 4. Finalize with commit 36 | - `git commit -m "Updated subtree from https://github.com/azure/azure-functions-language-worker-protobuf. Tag: . Commit: "` 37 | - `git push` 38 | 39 | ## Consuming FunctionRPC.proto 40 | *Note: Update versionNumber before running following commands* 41 | 42 | ## CSharp 43 | ``` 44 | set NUGET_PATH="%UserProfile%\.nuget\packages" 45 | set GRPC_TOOLS_PATH=%NUGET_PATH%\grpc.tools\\tools\windows_x86 46 | set PROTO_PATH=.\azure-functions-language-worker-protobuf\src\proto 47 | set PROTO=.\azure-functions-language-worker-protobuf\src\proto\FunctionRpc.proto 48 | set PROTOBUF_TOOLS=%NUGET_PATH%\google.protobuf.tools\\tools 49 | set MSGDIR=.\Messages 50 | 51 | if exist %MSGDIR% rmdir /s /q %MSGDIR% 52 | mkdir %MSGDIR% 53 | 54 | set OUTDIR=%MSGDIR%\DotNet 55 | mkdir %OUTDIR% 56 | %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% 57 | ``` 58 | ## JavaScript 59 | In package.json, add to the build script the following commands to build .js files and to build .ts files. Use and install npm package `protobufjs`. 60 | 61 | Generate JavaScript files: 62 | ``` 63 | pbjs -t json-module -w commonjs -o azure-functions-language-worker-protobuf/src/rpc.js azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto 64 | ``` 65 | Generate TypeScript files: 66 | ``` 67 | pbjs -t static-module azure-functions-language-worker-protobuf/src/proto/FunctionRpc.proto -o azure-functions-language-worker-protobuf/src/rpc_static.js && pbts -o azure-functions-language-worker-protobuf/src/rpc.d.ts azure-functions-language-worker-protobuf/src/rpc_static.js 68 | ``` 69 | 70 | ## Java 71 | Maven plugin : [protobuf-maven-plugin](https://www.xolstice.org/protobuf-maven-plugin/) 72 | In pom.xml add following under configuration for this plugin 73 | ${basedir}//azure-functions-language-worker-protobuf/src/proto 74 | 75 | ## Python 76 | ``` 77 | python -m pip install -e .[dev] -U 78 | python setup.py build 79 | ``` 80 | 81 | ## Contributing 82 | 83 | This project welcomes contributions and suggestions. Most contributions require you to agree to a 84 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us 85 | the rights to use your contribution. For details, visit https://cla.microsoft.com. 86 | 87 | When you submit a pull request, a CLA-bot will automatically determine whether you need to provide 88 | a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions 89 | provided by the bot. You will only need to do this once across all repos using our CLA. 90 | 91 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/). 92 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or 93 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments. 94 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Security 4 | 5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/). 6 | 7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below. 8 | 9 | ## Reporting Security Issues 10 | 11 | **Please do not report security vulnerabilities through public GitHub issues.** 12 | 13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report). 14 | 15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey). 16 | 17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc). 18 | 19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue: 20 | 21 | * Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.) 22 | * Full paths of source file(s) related to the manifestation of the issue 23 | * The location of the affected source code (tag/branch/commit or direct URL) 24 | * Any special configuration required to reproduce the issue 25 | * Step-by-step instructions to reproduce the issue 26 | * Proof-of-concept or exploit code (if possible) 27 | * Impact of the issue, including how an attacker might exploit the issue 28 | 29 | This information will help us triage your report more quickly. 30 | 31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs. 32 | 33 | ## Preferred Languages 34 | 35 | We prefer all communications to be in English. 36 | 37 | ## Policy 38 | 39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd). 40 | 41 | 42 | -------------------------------------------------------------------------------- /src/proto/FunctionRpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | // protobuf vscode extension: https://marketplace.visualstudio.com/items?itemName=zxh404.vscode-proto3 3 | 4 | option java_multiple_files = true; 5 | option java_package = "com.microsoft.azure.functions.rpc.messages"; 6 | option java_outer_classname = "FunctionProto"; 7 | option csharp_namespace = "Microsoft.Azure.WebJobs.Script.Grpc.Messages"; 8 | option go_package ="github.com/Azure/azure-functions-go-worker/internal/rpc"; 9 | 10 | package AzureFunctionsRpcMessages; 11 | 12 | import "google/protobuf/duration.proto"; 13 | import "identity/ClaimsIdentityRpc.proto"; 14 | import "shared/NullableTypes.proto"; 15 | 16 | // Interface exported by the server. 17 | service FunctionRpc { 18 | rpc EventStream (stream StreamingMessage) returns (stream StreamingMessage) {} 19 | } 20 | 21 | message StreamingMessage { 22 | // Used to identify message between host and worker 23 | string request_id = 1; 24 | 25 | // Payload of the message 26 | oneof content { 27 | 28 | // Worker initiates stream 29 | StartStream start_stream = 20; 30 | 31 | // Host sends capabilities/init data to worker 32 | WorkerInitRequest worker_init_request = 17; 33 | // Worker responds after initializing with its capabilities & status 34 | WorkerInitResponse worker_init_response = 16; 35 | 36 | // MESSAGE NOT USED 37 | // Worker periodically sends empty heartbeat message to host 38 | WorkerHeartbeat worker_heartbeat = 15; 39 | 40 | // Host sends terminate message to worker. 41 | // Worker terminates if it can, otherwise host terminates after a grace period 42 | WorkerTerminate worker_terminate = 14; 43 | 44 | // Host periodically sends status request to the worker 45 | WorkerStatusRequest worker_status_request = 12; 46 | WorkerStatusResponse worker_status_response = 13; 47 | 48 | // On file change event, host sends notification to worker 49 | FileChangeEventRequest file_change_event_request = 6; 50 | 51 | // Worker requests a desired action (restart worker, reload function) 52 | WorkerActionResponse worker_action_response = 7; 53 | 54 | // Host sends required metadata to worker to load function 55 | FunctionLoadRequest function_load_request = 8; 56 | // Worker responds after loading with the load result 57 | FunctionLoadResponse function_load_response = 9; 58 | 59 | // Host requests a given invocation 60 | InvocationRequest invocation_request = 4; 61 | 62 | // Worker responds to a given invocation 63 | InvocationResponse invocation_response = 5; 64 | 65 | // Host sends cancel message to attempt to cancel an invocation. 66 | // If an invocation is cancelled, host will receive an invocation response with status cancelled. 67 | InvocationCancel invocation_cancel = 21; 68 | 69 | // Worker logs a message back to the host 70 | RpcLog rpc_log = 2; 71 | 72 | FunctionEnvironmentReloadRequest function_environment_reload_request = 25; 73 | 74 | FunctionEnvironmentReloadResponse function_environment_reload_response = 26; 75 | 76 | // Ask the worker to close any open shared memory resources for a given invocation 77 | CloseSharedMemoryResourcesRequest close_shared_memory_resources_request = 27; 78 | CloseSharedMemoryResourcesResponse close_shared_memory_resources_response = 28; 79 | 80 | // Worker indexing message types 81 | FunctionsMetadataRequest functions_metadata_request = 29; 82 | FunctionMetadataResponse function_metadata_response = 30; 83 | 84 | // Host sends required metadata to worker to load functions 85 | FunctionLoadRequestCollection function_load_request_collection = 31; 86 | 87 | // Host gets the list of function load responses 88 | FunctionLoadResponseCollection function_load_response_collection = 32; 89 | 90 | // Host sends required metadata to worker to warmup the worker 91 | WorkerWarmupRequest worker_warmup_request = 33; 92 | 93 | // Worker responds after warming up with the warmup result 94 | WorkerWarmupResponse worker_warmup_response = 34; 95 | 96 | } 97 | } 98 | 99 | // Process.Start required info 100 | // connection details 101 | // protocol type 102 | // protocol version 103 | 104 | // Worker sends the host information identifying itself 105 | message StartStream { 106 | // id of the worker 107 | string worker_id = 2; 108 | } 109 | 110 | // Host requests the worker to initialize itself 111 | message WorkerInitRequest { 112 | // version of the host sending init request 113 | string host_version = 1; 114 | 115 | // A map of host supported features/capabilities 116 | map capabilities = 2; 117 | 118 | // inform worker of supported categories and their levels 119 | // i.e. Worker = Verbose, Function.MyFunc = None 120 | map log_categories = 3; 121 | 122 | // Full path of worker.config.json location 123 | string worker_directory = 4; 124 | 125 | // base directory for function app 126 | string function_app_directory = 5; 127 | } 128 | 129 | // Worker responds with the result of initializing itself 130 | message WorkerInitResponse { 131 | // PROPERTY NOT USED 132 | // TODO: Remove from protobuf during next breaking change release 133 | string worker_version = 1; 134 | 135 | // A map of worker supported features/capabilities 136 | map capabilities = 2; 137 | 138 | // Status of the response 139 | StatusResult result = 3; 140 | 141 | // Worker metadata captured for telemetry purposes 142 | WorkerMetadata worker_metadata = 4; 143 | } 144 | 145 | message WorkerMetadata { 146 | // The runtime/stack name 147 | string runtime_name = 1; 148 | 149 | // The version of the runtime/stack 150 | string runtime_version = 2; 151 | 152 | // The version of the worker 153 | string worker_version = 3; 154 | 155 | // The worker bitness/architecture 156 | string worker_bitness = 4; 157 | 158 | // Optional additional custom properties 159 | map custom_properties = 5; 160 | } 161 | 162 | // Used by the host to determine success/failure/cancellation 163 | message StatusResult { 164 | // Indicates Failure/Success/Cancelled 165 | enum Status { 166 | Failure = 0; 167 | Success = 1; 168 | Cancelled = 2; 169 | } 170 | 171 | // Status for the given result 172 | Status status = 4; 173 | 174 | // Specific message about the result 175 | string result = 1; 176 | 177 | // Exception message (if exists) for the status 178 | RpcException exception = 2; 179 | 180 | // Captured logs or relevant details can use the logs property 181 | repeated RpcLog logs = 3; 182 | } 183 | 184 | // MESSAGE NOT USED 185 | // TODO: Remove from protobuf during next breaking change release 186 | message WorkerHeartbeat {} 187 | 188 | // Warning before killing the process after grace_period 189 | // Worker self terminates ..no response on this 190 | message WorkerTerminate { 191 | google.protobuf.Duration grace_period = 1; 192 | } 193 | 194 | // Host notifies worker of file content change 195 | message FileChangeEventRequest { 196 | // Types of File change operations (See link for more info: https://msdn.microsoft.com/en-us/library/t6xf43e0(v=vs.110).aspx) 197 | enum Type { 198 | Unknown = 0; 199 | Created = 1; 200 | Deleted = 2; 201 | Changed = 4; 202 | Renamed = 8; 203 | All = 15; 204 | } 205 | 206 | // type for this event 207 | Type type = 1; 208 | 209 | // full file path for the file change notification 210 | string full_path = 2; 211 | 212 | // Name of the function affected 213 | string name = 3; 214 | } 215 | 216 | // Indicates whether worker reloaded successfully or needs a restart 217 | message WorkerActionResponse { 218 | // indicates whether a restart is needed, or reload successfully 219 | enum Action { 220 | Restart = 0; 221 | Reload = 1; 222 | } 223 | 224 | // action for this response 225 | Action action = 1; 226 | 227 | // text reason for the response 228 | string reason = 2; 229 | } 230 | 231 | // Used by the host to determine worker health 232 | message WorkerStatusRequest { 233 | } 234 | 235 | // Worker responds with status message 236 | // TODO: Add any worker relevant status to response 237 | message WorkerStatusResponse { 238 | } 239 | 240 | message FunctionEnvironmentReloadRequest { 241 | // Environment variables from the current process 242 | map environment_variables = 1; 243 | // Current directory of function app 244 | string function_app_directory = 2; 245 | } 246 | 247 | message FunctionEnvironmentReloadResponse { 248 | enum CapabilitiesUpdateStrategy { 249 | // overwrites existing values and appends new ones 250 | // ex. worker init: {A: foo, B: bar} + env reload: {A:foo, B: foo, C: foo} -> {A: foo, B: foo, C: foo} 251 | merge = 0; 252 | // existing capabilities are cleared and new capabilities are applied 253 | // ex. worker init: {A: foo, B: bar} + env reload: {A:foo, C: foo} -> {A: foo, C: foo} 254 | replace = 1; 255 | } 256 | // After specialization, worker sends capabilities & metadata. 257 | // Worker metadata captured for telemetry purposes 258 | WorkerMetadata worker_metadata = 1; 259 | 260 | // A map of worker supported features/capabilities 261 | map capabilities = 2; 262 | 263 | // Status of the response 264 | StatusResult result = 3; 265 | 266 | // If no strategy is defined, the host will default to merge 267 | CapabilitiesUpdateStrategy capabilities_update_strategy = 4; 268 | } 269 | 270 | // Tell the out-of-proc worker to close any shared memory maps it allocated for given invocation 271 | message CloseSharedMemoryResourcesRequest { 272 | repeated string map_names = 1; 273 | } 274 | 275 | // Response from the worker indicating which of the shared memory maps have been successfully closed and which have not been closed 276 | // The key (string) is the map name and the value (bool) is true if it was closed, false if not 277 | message CloseSharedMemoryResourcesResponse { 278 | map close_map_results = 1; 279 | } 280 | 281 | // Host tells the worker to load a list of Functions 282 | message FunctionLoadRequestCollection { 283 | repeated FunctionLoadRequest function_load_requests = 1; 284 | } 285 | 286 | // Host gets the list of function load responses 287 | message FunctionLoadResponseCollection { 288 | repeated FunctionLoadResponse function_load_responses = 1; 289 | } 290 | 291 | // Load request of a single Function 292 | message FunctionLoadRequest { 293 | // unique function identifier (avoid name collisions, facilitate reload case) 294 | string function_id = 1; 295 | 296 | // Metadata for the request 297 | RpcFunctionMetadata metadata = 2; 298 | 299 | // A flag indicating if managed dependency is enabled or not 300 | bool managed_dependency_enabled = 3; 301 | } 302 | 303 | // Worker tells host result of reload 304 | message FunctionLoadResponse { 305 | // unique function identifier 306 | string function_id = 1; 307 | 308 | // Result of load operation 309 | StatusResult result = 2; 310 | // TODO: return type expected? 311 | 312 | // Result of load operation 313 | bool is_dependency_downloaded = 3; 314 | } 315 | 316 | // Information on how a Function should be loaded and its bindings 317 | message RpcFunctionMetadata { 318 | // TODO: do we want the host's name - the language worker might do a better job of assignment than the host 319 | string name = 4; 320 | 321 | // base directory for the Function 322 | string directory = 1; 323 | 324 | // Script file specified 325 | string script_file = 2; 326 | 327 | // Entry point specified 328 | string entry_point = 3; 329 | 330 | // Bindings info 331 | map bindings = 6; 332 | 333 | // Is set to true for proxy 334 | bool is_proxy = 7; 335 | 336 | // Function indexing status 337 | StatusResult status = 8; 338 | 339 | // Function language 340 | string language = 9; 341 | 342 | // Raw binding info 343 | repeated string raw_bindings = 10; 344 | 345 | // unique function identifier (avoid name collisions, facilitate reload case) 346 | string function_id = 13; 347 | 348 | // A flag indicating if managed dependency is enabled or not 349 | bool managed_dependency_enabled = 14; 350 | 351 | // The optional function execution retry strategy to use on invocation failures. 352 | RpcRetryOptions retry_options = 15; 353 | 354 | // Properties for function metadata 355 | // They're usually specific to a worker and largely passed along to the controller API for use 356 | // outside the host 357 | map properties = 16; 358 | } 359 | 360 | // Host tells worker it is ready to receive metadata 361 | message FunctionsMetadataRequest { 362 | // base directory for function app 363 | string function_app_directory = 1; 364 | } 365 | 366 | // Worker sends function metadata back to host 367 | message FunctionMetadataResponse { 368 | // list of function indexing responses 369 | repeated RpcFunctionMetadata function_metadata_results = 1; 370 | 371 | // status of overall metadata request 372 | StatusResult result = 2; 373 | 374 | // if set to true then host will perform indexing 375 | bool use_default_metadata_indexing = 3; 376 | } 377 | 378 | // Host requests worker to invoke a Function 379 | message InvocationRequest { 380 | // Unique id for each invocation 381 | string invocation_id = 1; 382 | 383 | // Unique id for each Function 384 | string function_id = 2; 385 | 386 | // Input bindings (include trigger) 387 | repeated ParameterBinding input_data = 3; 388 | 389 | // binding metadata from trigger 390 | map trigger_metadata = 4; 391 | 392 | // Populates activityId, tracestate and tags from host 393 | RpcTraceContext trace_context = 5; 394 | 395 | // Current retry context 396 | RetryContext retry_context = 6; 397 | } 398 | 399 | // Host sends ActivityId, traceStateString and Tags from host 400 | message RpcTraceContext { 401 | // This corresponds to Activity.Current?.Id 402 | string trace_parent = 1; 403 | 404 | // This corresponds to Activity.Current?.TraceStateString 405 | string trace_state = 2; 406 | 407 | // This corresponds to Activity.Current?.Tags 408 | map attributes = 3; 409 | } 410 | 411 | // Host sends retry context for a function invocation 412 | message RetryContext { 413 | // Current retry count 414 | int32 retry_count = 1; 415 | 416 | // Max retry count 417 | int32 max_retry_count = 2; 418 | 419 | // Exception that caused the retry 420 | RpcException exception = 3; 421 | } 422 | 423 | // Host requests worker to cancel invocation 424 | message InvocationCancel { 425 | // Unique id for invocation 426 | string invocation_id = 2; 427 | 428 | // PROPERTY NOT USED 429 | google.protobuf.Duration grace_period = 1; 430 | } 431 | 432 | // Worker responds with status of Invocation 433 | message InvocationResponse { 434 | // Unique id for invocation 435 | string invocation_id = 1; 436 | 437 | // Output binding data 438 | repeated ParameterBinding output_data = 2; 439 | 440 | // data returned from Function (for $return and triggers with return support) 441 | TypedData return_value = 4; 442 | 443 | // Status of the invocation (success/failure/canceled) 444 | StatusResult result = 3; 445 | } 446 | 447 | message WorkerWarmupRequest { 448 | // Full path of worker.config.json location 449 | string worker_directory = 1; 450 | } 451 | 452 | message WorkerWarmupResponse { 453 | StatusResult result = 1; 454 | } 455 | 456 | // Used to encapsulate data which could be a variety of types 457 | message TypedData { 458 | oneof data { 459 | string string = 1; 460 | string json = 2; 461 | bytes bytes = 3; 462 | bytes stream = 4; 463 | RpcHttp http = 5; 464 | sint64 int = 6; 465 | double double = 7; 466 | CollectionBytes collection_bytes = 8; 467 | CollectionString collection_string = 9; 468 | CollectionDouble collection_double = 10; 469 | CollectionSInt64 collection_sint64 = 11; 470 | ModelBindingData model_binding_data = 12; 471 | CollectionModelBindingData collection_model_binding_data = 13; 472 | } 473 | } 474 | 475 | // Specify which type of data is contained in the shared memory region being read 476 | enum RpcDataType { 477 | unknown = 0; 478 | string = 1; 479 | json = 2; 480 | bytes = 3; 481 | stream = 4; 482 | http = 5; 483 | int = 6; 484 | double = 7; 485 | collection_bytes = 8; 486 | collection_string = 9; 487 | collection_double = 10; 488 | collection_sint64 = 11; 489 | } 490 | 491 | // Used to provide metadata about shared memory region to read data from 492 | message RpcSharedMemory { 493 | // Name of the shared memory map containing data 494 | string name = 1; 495 | // Offset in the shared memory map to start reading data from 496 | int64 offset = 2; 497 | // Number of bytes to read (starting from the offset) 498 | int64 count = 3; 499 | // Final type to which the read data (in bytes) is to be interpreted as 500 | RpcDataType type = 4; 501 | } 502 | 503 | // Used to encapsulate collection string 504 | message CollectionString { 505 | repeated string string = 1; 506 | } 507 | 508 | // Used to encapsulate collection bytes 509 | message CollectionBytes { 510 | repeated bytes bytes = 1; 511 | } 512 | 513 | // Used to encapsulate collection double 514 | message CollectionDouble { 515 | repeated double double = 1; 516 | } 517 | 518 | // Used to encapsulate collection sint64 519 | message CollectionSInt64 { 520 | repeated sint64 sint64 = 1; 521 | } 522 | 523 | // Used to describe a given binding on invocation 524 | message ParameterBinding { 525 | // Name for the binding 526 | string name = 1; 527 | 528 | oneof rpc_data { 529 | // Data for the binding 530 | TypedData data = 2; 531 | 532 | // Metadata about the shared memory region to read data from 533 | RpcSharedMemory rpc_shared_memory = 3; 534 | } 535 | } 536 | 537 | // Used to describe a given binding on load 538 | message BindingInfo { 539 | // Indicates whether it is an input or output binding (or a fancy inout binding) 540 | enum Direction { 541 | in = 0; 542 | out = 1; 543 | inout = 2; 544 | } 545 | 546 | // Indicates the type of the data for the binding 547 | enum DataType { 548 | undefined = 0; 549 | string = 1; 550 | binary = 2; 551 | stream = 3; 552 | } 553 | 554 | // Type of binding (e.g. HttpTrigger) 555 | string type = 2; 556 | 557 | // Direction of the given binding 558 | Direction direction = 3; 559 | 560 | DataType data_type = 4; 561 | 562 | // Properties for binding metadata 563 | map properties = 5; 564 | } 565 | 566 | // Used to send logs back to the Host 567 | message RpcLog { 568 | // Matching ILogger semantics 569 | // https://github.com/aspnet/Logging/blob/9506ccc3f3491488fe88010ef8b9eb64594abf95/src/Microsoft.Extensions.Logging/Logger.cs 570 | // Level for the Log 571 | enum Level { 572 | Trace = 0; 573 | Debug = 1; 574 | Information = 2; 575 | Warning = 3; 576 | Error = 4; 577 | Critical = 5; 578 | None = 6; 579 | } 580 | 581 | // Category of the log. Defaults to User if not specified. 582 | enum RpcLogCategory { 583 | User = 0; 584 | System = 1; 585 | CustomMetric = 2; 586 | } 587 | 588 | // Unique id for invocation (if exists) 589 | string invocation_id = 1; 590 | 591 | // TOD: This should be an enum 592 | // Category for the log (startup, load, invocation, etc.) 593 | string category = 2; 594 | 595 | // Level for the given log message 596 | Level level = 3; 597 | 598 | // Message for the given log 599 | string message = 4; 600 | 601 | // Id for the even associated with this log (if exists) 602 | string event_id = 5; 603 | 604 | // Exception (if exists) 605 | RpcException exception = 6; 606 | 607 | // json serialized property bag 608 | string properties = 7; 609 | 610 | // Category of the log. Either user(default), system, or custom metric. 611 | RpcLogCategory log_category = 8; 612 | 613 | // strongly-typed (ish) property bag 614 | map propertiesMap = 9; 615 | } 616 | 617 | // Encapsulates an Exception 618 | message RpcException { 619 | // Source of the exception 620 | string source = 3; 621 | 622 | // Stack trace for the exception 623 | string stack_trace = 1; 624 | 625 | // Textual message describing the exception 626 | string message = 2; 627 | 628 | // Worker specifies whether exception is a user exception, 629 | // for purpose of application insights logging. Defaults to false. 630 | bool is_user_exception = 4; 631 | 632 | // Type of exception. If it's a user exception, the type is passed along to app insights. 633 | // Otherwise, it's ignored for now. 634 | string type = 5; 635 | } 636 | 637 | // Http cookie type. Note that only name and value are used for Http requests 638 | message RpcHttpCookie { 639 | // Enum that lets servers require that a cookie shouldn't be sent with cross-site requests 640 | enum SameSite { 641 | None = 0; 642 | Lax = 1; 643 | Strict = 2; 644 | ExplicitNone = 3; 645 | } 646 | 647 | // Cookie name 648 | string name = 1; 649 | 650 | // Cookie value 651 | string value = 2; 652 | 653 | // Specifies allowed hosts to receive the cookie 654 | NullableString domain = 3; 655 | 656 | // Specifies URL path that must exist in the requested URL 657 | NullableString path = 4; 658 | 659 | // Sets the cookie to expire at a specific date instead of when the client closes. 660 | // It is generally recommended that you use "Max-Age" over "Expires". 661 | NullableTimestamp expires = 5; 662 | 663 | // Sets the cookie to only be sent with an encrypted request 664 | NullableBool secure = 6; 665 | 666 | // Sets the cookie to be inaccessible to JavaScript's Document.cookie API 667 | NullableBool http_only = 7; 668 | 669 | // Allows servers to assert that a cookie ought not to be sent along with cross-site requests 670 | SameSite same_site = 8; 671 | 672 | // Number of seconds until the cookie expires. A zero or negative number will expire the cookie immediately. 673 | NullableDouble max_age = 9; 674 | } 675 | 676 | // TODO - solidify this or remove it 677 | message RpcHttp { 678 | string method = 1; 679 | string url = 2; 680 | map headers = 3; 681 | TypedData body = 4; 682 | map params = 10; 683 | string status_code = 12; 684 | map query = 15; 685 | bool enable_content_negotiation= 16; 686 | TypedData rawBody = 17; 687 | repeated RpcClaimsIdentity identities = 18; 688 | repeated RpcHttpCookie cookies = 19; 689 | map nullable_headers = 20; 690 | map nullable_params = 21; 691 | map nullable_query = 22; 692 | } 693 | 694 | // Message representing Microsoft.Azure.WebJobs.ParameterBindingData 695 | // Used for hydrating SDK-type bindings in out-of-proc workers 696 | message ModelBindingData 697 | { 698 | // The version of the binding data content 699 | string version = 1; 700 | 701 | // The extension source of the binding data 702 | string source = 2; 703 | 704 | // The content type of the binding data content 705 | string content_type = 3; 706 | 707 | // The binding data content 708 | bytes content = 4; 709 | } 710 | 711 | // Used to encapsulate collection model_binding_data 712 | message CollectionModelBindingData { 713 | repeated ModelBindingData model_binding_data = 1; 714 | } 715 | 716 | // Retry policy which the worker sends the host when the worker indexes 717 | // a function. 718 | message RpcRetryOptions 719 | { 720 | // The retry strategy to use. Valid values are fixed delay or exponential backoff. 721 | enum RetryStrategy 722 | { 723 | exponential_backoff = 0; 724 | fixed_delay = 1; 725 | } 726 | 727 | // The maximum number of retries allowed per function execution. 728 | // -1 means to retry indefinitely. 729 | int32 max_retry_count = 2; 730 | 731 | // The delay that's used between retries when you're using a fixed delay strategy. 732 | google.protobuf.Duration delay_interval = 3; 733 | 734 | // The minimum retry delay when you're using an exponential backoff strategy 735 | google.protobuf.Duration minimum_interval = 4; 736 | 737 | // The maximum retry delay when you're using an exponential backoff strategy 738 | google.protobuf.Duration maximum_interval = 5; 739 | 740 | RetryStrategy retry_strategy = 6; 741 | } 742 | -------------------------------------------------------------------------------- /src/proto/identity/ClaimsIdentityRpc.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | // protobuf vscode extension: https://marketplace.visualstudio.com/items?itemName=zxh404.vscode-proto3 3 | 4 | option java_package = "com.microsoft.azure.functions.rpc.messages"; 5 | 6 | import "shared/NullableTypes.proto"; 7 | 8 | // Light-weight representation of a .NET System.Security.Claims.ClaimsIdentity object. 9 | // This is the same serialization as found in EasyAuth, and needs to be kept in sync with 10 | // its ClaimsIdentitySlim definition, as seen in the WebJobs extension: 11 | // https://github.com/Azure/azure-webjobs-sdk-extensions/blob/dev/src/WebJobs.Extensions.Http/ClaimsIdentitySlim.cs 12 | message RpcClaimsIdentity { 13 | NullableString authentication_type = 1; 14 | NullableString name_claim_type = 2; 15 | NullableString role_claim_type = 3; 16 | repeated RpcClaim claims = 4; 17 | } 18 | 19 | // Light-weight representation of a .NET System.Security.Claims.Claim object. 20 | // This is the same serialization as found in EasyAuth, and needs to be kept in sync with 21 | // its ClaimSlim definition, as seen in the WebJobs extension: 22 | // https://github.com/Azure/azure-webjobs-sdk-extensions/blob/dev/src/WebJobs.Extensions.Http/ClaimSlim.cs 23 | message RpcClaim { 24 | string value = 1; 25 | string type = 2; 26 | } 27 | -------------------------------------------------------------------------------- /src/proto/shared/NullableTypes.proto: -------------------------------------------------------------------------------- 1 | syntax = "proto3"; 2 | // protobuf vscode extension: https://marketplace.visualstudio.com/items?itemName=zxh404.vscode-proto3 3 | 4 | option java_package = "com.microsoft.azure.functions.rpc.messages"; 5 | 6 | import "google/protobuf/timestamp.proto"; 7 | 8 | message NullableString { 9 | oneof string { 10 | string value = 1; 11 | } 12 | } 13 | 14 | message NullableDouble { 15 | oneof double { 16 | double value = 1; 17 | } 18 | } 19 | 20 | message NullableBool { 21 | oneof bool { 22 | bool value = 1; 23 | } 24 | } 25 | 26 | message NullableTimestamp { 27 | oneof timestamp { 28 | google.protobuf.Timestamp value = 1; 29 | } 30 | } 31 | --------------------------------------------------------------------------------