forked from Azure/azure-functions-dapr-extension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adding documentation Signed-off-by: MD Ashique <[email protected]> * Adding documentation Signed-off-by: MD Ashique <[email protected]> * Adding documentation Signed-off-by: MD Ashique <[email protected]> * Adding documentation Signed-off-by: MD Ashique <[email protected]> * Adding documentation for tenant id Signed-off-by: MD Ashique <[email protected]> * Adding documentation Signed-off-by: MD Ashique <[email protected]> * Adding documentation Signed-off-by: MD Ashique <[email protected]> --------- Signed-off-by: MD Ashique <[email protected]>
- Loading branch information
Showing
20 changed files
with
248 additions
and
210 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
samples/sample-infra/README.md → deploy/aca/aca-deployment.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
# Quickstart: Deploying to Kubernetes | ||
|
||
You can annotate your function Kubernetes deployments to include the Dapr sidecar. | ||
|
||
> IMPORTANT: Port 3001 will only be exposed and listened if a Dapr trigger is defined in the function app. When using Dapr, the sidecar will wait to receive a response from the defined port before completing instantiation. This means it is important to NOT define the `dapr.io/port` annotation or `--app-port` unless you have a trigger. Doing so may lock your application from the Dapr sidecar. Port 3001 does not need to be exposed or defined if only using input and output bindings. | ||
To generate a Dockerfile for your app if you don't already have one, you can run the following command in your function project: | ||
`func init --docker-only`. | ||
|
||
The Azure Function core tools can automatically generate for you Kubernetes deployment files based on your local app. It's worth noting these manifests expect [KEDA](https://keda.sh) will be present to manage scaling, so if not using KEDA you may need to remove the `ScaledObjects` generated, or craft your own deployment YAML file. We do recommend including KEDA in any cluster that is running Azure Functions containers (with or without Dapr), but it is an optional component to assist with scaling. | ||
|
||
An example of a function app deployment for Kubernetes can be [found below](#sample-kubernetes-deployment). | ||
|
||
The following command will generate a `deploy.yaml` file for your project: | ||
`func kubernetes deploy --name {container-name} --registry {docker-registry} --dry-run > deploy.yaml` | ||
|
||
You can then edit the generated `deploy.yaml` to add the dapr annotations. You can also craft a deployment manually. | ||
|
||
### Azure Storage account requirements | ||
|
||
While an Azure Storage account is required to run functions within Azure, it is NOT required for functions that run in Kubernetes or from a Docker container. The exception to that is functions that leverage a Timer trigger or Event Hub trigger. In those cases the storage account is used to coordinate leases for instances, so you will need to set an `AzureWebJobsStorage` connection string if using those triggers. You can set the `AzureWebJobsStorage` value to `none` if not using any of the triggers that require it. | ||
|
||
### Sample Kubernetes deployment | ||
|
||
```yml | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: my-function | ||
namespace: default | ||
spec: | ||
selector: | ||
app: my-function | ||
ports: | ||
- protocol: TCP | ||
port: 80 | ||
targetPort: 80 | ||
type: LoadBalancer | ||
--- | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: my-function | ||
namespace: default | ||
labels: | ||
app: my-function | ||
spec: | ||
replicas: 1 | ||
selector: | ||
matchLabels: | ||
app: my-function | ||
template: | ||
metadata: | ||
labels: | ||
app: my-function | ||
annotations: | ||
dapr.io/enabled: "true" | ||
dapr.io/id: "functionapp" | ||
# Only define port of Dapr triggers are included | ||
dapr.io/port: "3001" | ||
spec: | ||
containers: | ||
- name: my-function | ||
image: myregistry/my-function | ||
ports: | ||
# Port for HTTP triggered functions | ||
- containerPort: 80 | ||
--- | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
# Quickstart: Deploying to Local | ||
|
||
## Installing the extension | ||
|
||
### .NET Functions | ||
|
||
Run the following command from the path where your csproj is located to add the Nuget package to your Azure Function project | ||
|
||
**Isolated Worker Process:** | ||
|
||
``` | ||
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.Dapr --prerelease | ||
``` | ||
|
||
**In-process** | ||
|
||
``` | ||
dotnet add package Microsoft.Azure.WebJobs.Extensions.Dapr --prerelease | ||
``` | ||
|
||
### Non-.NET Functions | ||
|
||
Since this extension is in Preview, you need to add the preview extension by adding or replacing the following code in your host.json file: | ||
|
||
``` | ||
{ | ||
"version": "2.0", | ||
"extensionBundle": { | ||
"id": "Microsoft.Azure.Functions.ExtensionBundle.Preview", | ||
"version": "[4.*, 5.0.0)" | ||
} | ||
} | ||
``` | ||
|
||
## Using Dapr Extension local build | ||
|
||
The samples in this repo (other than the quickstart) are set up to run using a local build of the extension. | ||
|
||
You can use a development build of the extension for any function by: | ||
|
||
- Referencing the Microsoft.Azure.WebJobs.Extensions.Dapr project in your .NET function | ||
- Publishing the extension to the `bin/` directory of your non-.NET function | ||
|
||
Example for non-.NET function: | ||
|
||
```sh | ||
dotnet publish /path/to/Microsoft.Azure.WebJobs.Extensions.Dapr -o bin/ | ||
``` | ||
|
||
## Running and debugging an app | ||
|
||
Normally when debugging an Azure Function you use the `func` command line tool to start up the function app process and trigger your code. When debugging or running an Azure Function that will leverage Dapr, you need to use `dapr` alongside `func` so both processes are running. | ||
|
||
So when running a Dapr app locally using the default ports, you would leverage the `dapr` CLI to start the `func` CLI. | ||
|
||
### If no Dapr triggers are in the app | ||
```sh | ||
dapr run --app-id functionA --dapr-http-port 3501 -- func host start --no-build | ||
``` | ||
|
||
### If Dapr triggers are in the app | ||
```sh | ||
dapr run --app-id functionA --app-port 3001 --dapr-http-port 3501 -- func host start --no-build | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,69 @@ | ||
# Setup Local Development | ||
|
||
This document is a TODO. | ||
This guide will help you set up the Azure Functions Dapr Extension in your local development environment. Follow these steps to get started. | ||
|
||
## Prerequisites | ||
|
||
## Clone the repository | ||
Before you begin, ensure you have the following prerequisites installed: | ||
|
||
- Setup Dapr: Follow instructions to [download and install the Dapr CLI](https://docs.dapr.io/getting-started/install-dapr-cli/) and [initialize Dapr](https://docs.dapr.io/getting-started/install-dapr-selfhost/) | ||
- [Azure Functions Core Tools](https://docs.microsoft.com/en-us/azure/azure-functions/functions-run-local) | ||
- [.NET SDK](https://dotnet.microsoft.com/download) | ||
- [Docker](https://www.docker.com/get-started) | ||
- [Setup Dapr components](https://github.com/Azure/azure-functions-dapr-extension/tree/master/samples/components) if you need one | ||
|
||
## Clone the Repository | ||
|
||
To start, clone the Azure Functions Dapr Extension repository to your local machine. Use the following command in your terminal or Git client: | ||
|
||
```bash | ||
git clone https://github.com/Azure/azure-functions-dapr-extension.git | ||
``` | ||
|
||
## Build the project | ||
Once you have cloned the repository, navigate to the project directory and build the project. Use the following commands: | ||
``` | ||
cd azure-functions-dapr-extension | ||
dotnet build | ||
``` | ||
|
||
## Run tests | ||
|
||
To ensure everything is functioning correctly, it's a good practice to run the tests. Use the following command to run the tests: | ||
``` | ||
dotnet test | ||
``` | ||
## Debugging | ||
To debug the Azure Functions Dapr Extension locally, you can use your preferred development environment, such as Visual Studio Code or Visual Studio. Set breakpoints in your code where needed, and use the appropriate debugging tools for your chosen development environment. | ||
|
||
### Debugging in Visual Studio Code | ||
1. Create/reuse existing samples to debug the extension. | ||
2. Run the function app with below command. | ||
|
||
> [!WARNING] | ||
> Provide ` --app-port 3001` only when you have Dapr trigger(s) in your Azure function | ||
``` | ||
dapr run --app-id functionapp --app-port 3001 --dapr-http-port 3501 -- func host start | ||
``` | ||
3. Open Visual Studio Code, navigate to the project folder, and open the relevant code file. | ||
4. Add breakpoints in your code where needed. | ||
5. In Visual Studio Code, open the "Run and Debug" sidebar, select the configuration for your function, and click the "Run" button. | ||
6. Visual Studio Code will automatically attach the debugger to the running process, and you can enjoy debugging. | ||
|
||
### Debugging in Visual Studio | ||
1. Create/reuse existing samples to debug the extension. | ||
2. Run the function app with below command. | ||
|
||
> [!WARNING] | ||
> Provide ` --app-port 3001` only when you have Dapr trigger(s) in your Azure function | ||
``` | ||
dapr run --app-id functionapp --app-port 3001 --dapr-http-port 3501 -- func host start | ||
``` | ||
3. Open Visual Studio, navigate to the project folder, and open the relevant code file. | ||
4. Add breakpoints in your code where needed. | ||
5. In Visual Studio, select the "Debug" menu, then choose "Attach to Process..." | ||
6. Choose the func process or provide the corresponding process ID. | ||
7. Click the "Attach" button to attach the debugger. | ||
|
||
|
||
That's it! You're now set up for local development with the Azure Functions Dapr Extension. You can start building and testing your Azure Functions with Dapr support locally. |
Oops, something went wrong.