https://github.com/anthonychu/functions-customhandlers-aspnetcore
https://github.com/anthonychu/functions-customhandlers-aspnetcore
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/anthonychu/functions-customhandlers-aspnetcore
- Owner: anthonychu
- Created: 2020-04-14T17:26:57.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T14:56:19.000Z (over 2 years ago)
- Last Synced: 2025-02-12T08:31:50.466Z (3 months ago)
- Language: JavaScript
- Size: 3.82 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 25
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# ASP.NET Core in Azure Functions Custom Handlers
> Important: This is a quick proof of concept and how this works is subject to change until [custom handlers](https://docs.microsoft.com/en-us/azure/azure-functions/functions-custom-handlers) reaches general availability.
## dotnet-react (.NET Core + React app)
This is an ASP.NET Core app built with `dotnet new react`. There were 3 main changes:
* `Program.cs`
- Listen to `FUNCTIONS_HTTPWORKER_PORT`.
- Change current working directory to `server` as the app will run from a subfolder within a function app. This is configured using an app setting named `ServerSubfolder`.
* `Startup.cs`
- Add middleware to rewrite the request path using the `__path__` query string.### Build and publish the app
Publish the app into a folder named `server` in the function app.
```bash
cd dotnet-react
dotnet publish -c Release -o ../function-app/server
```## function-app (main Azure Functions app)
This is the main function app. `host.json` has been configured to start `dotnet server/dotnet-react.dll` as the custom hander.
A proxy is configured in `proxies.json` to forward all requests to `/api/index?__path__={path}` in the function app. This is currently needed as the original path required for routing in ASP.NET Core is lost when the custom handler is invoked.
There's an `index` function that invokes the custom handler.
### Run locally
```bash
func start
```### Publish to Azure
Create a function app in the Windows consumption plan, then publish with this command:
```bash
func azure functionapp publish $FUNCTION_APP_NAME --no-build -b local --force
```