|
| 1 | +# Asynchronous Request-Reply pattern |
| 2 | + |
| 3 | +Decouple backend processing from a frontend host, where backend processing needs to be asynchronous, but the frontend still needs a clear response. |
| 4 | + |
| 5 | +For more information about this pattern, see [Asynchronous Request-Reply pattern](https://docs.microsoft.com/azure/architecture/patterns/async-request-reply) on the Azure Architecture Center. |
| 6 | + |
| 7 | + |
| 8 | + |
| 9 | +## Deploying the sample |
| 10 | + |
| 11 | +### Prerequisites |
| 12 | + |
| 13 | +- [Azure CLI](https://docs.microsoft.com/cli/azure/install-azure-cli?view=azure-cli-latest) |
| 14 | +- [.NET Core SDK version 2.1](https://microsoft.com/net) |
| 15 | +- [Azure Functions Core Tools](https://docs.microsoft.com/azure/azure-functions/functions-run-local#v2) |
| 16 | + |
| 17 | +### Deploy the Azure resources |
| 18 | + |
| 19 | +1. Clone or download this repo. |
| 20 | + |
| 21 | +2. Navigate to the `async-request-reply` folder. |
| 22 | + |
| 23 | + ```bash |
| 24 | + cd async-request-reply/async-request-reply |
| 25 | + ``` |
| 26 | + |
| 27 | +3. Create a resource group. |
| 28 | + |
| 29 | + ```bash |
| 30 | + export RESOURCE_GROUP=<resource-group-name> |
| 31 | + export APP_NAME=<app-name> # 2-6 characters |
| 32 | + export LOCATION=<azure-region> |
| 33 | +
|
| 34 | + az group create --name $RESOURCE_GROUP --location $LOCATION |
| 35 | + ``` |
| 36 | + |
| 37 | +4. Deploy the template. |
| 38 | + |
| 39 | + ```bash |
| 40 | + az group deployment create \ |
| 41 | + --resource-group $RESOURCE_GROUP \ |
| 42 | + --template-file deploy.json \ |
| 43 | + --parameters appName=$APP_NAME |
| 44 | + ``` |
| 45 | + |
| 46 | +5. Wait for the deployment to complete. |
| 47 | + |
| 48 | +### Deploy the Functions app |
| 49 | + |
| 50 | +1. Navigate to the `async-request-reply/src` folder. |
| 51 | + |
| 52 | + ```bash |
| 53 | + cd src |
| 54 | + ``` |
| 55 | + |
| 56 | +2. Deploy the app. |
| 57 | + |
| 58 | + ```bash |
| 59 | + func azure functionapp publish $(APP_NAME)-fn |
| 60 | + ``` |
| 61 | + |
| 62 | +### Send a request |
| 63 | + |
| 64 | +```bash |
| 65 | +curl -X POST "https://$(APP_NAME)-fn.azurewebsites.net/api/asyncprocessingworkacceptor" --header 'Content-Type: application/json' --header 'Accept: application/json' -k -i -d '{ |
| 66 | + "id": "1234", |
| 67 | + "customername": "Contoso" |
| 68 | + }' |
| 69 | + ``` |
| 70 | + |
| 71 | + > Note. The app uses the WEBSITE_HOSTNAME environment variable. This environment variable is set automatically by the Azure App Service runtime environment. For more information, see [Azure runtime environment](https.://github.com/projectkudu/kudu/wiki/Azure-runtime-environment) |
0 commit comments