Skip to content

Commit e14d34b

Browse files
committed
added section about env vars before deployment
1 parent bec7003 commit e14d34b

File tree

1 file changed

+60
-29
lines changed

1 file changed

+60
-29
lines changed

articles/azure-functions/durable/durable-task-scheduler/quickstart-durable-task-scheduler.md

Lines changed: 60 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -55,42 +55,55 @@ You'll also need:
5555
- [Azurite](../../../storage/common/storage-use-azurite.md#run-azurite) installed.
5656
- An [HTTP test tool](../../functions-develop-local.md#http-test-tools) that keeps your data secure.
5757

58-
::: zone pivot="csharp"
58+
## Add the Durable Task Scheduler package
5959

60-
## Add the Durable Task Scheduler extension
60+
::: zone pivot="csharp"
6161

6262
> [!NOTE]
6363
> The DTS extension requires **Microsoft.Azure.Functions.Worker.Extensions.DurableTask** version `1.2.2` or higher.
6464
65-
Install the latest version of the [Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged) extension from NuGet. There are several ways of doing this:
66-
67-
1. Add a reference to the extension in your _.csproj_ file and then build the project.
68-
69-
1. Use the [dotnet add package](/dotnet/core/tools/dotnet-add-package) command to add extension packages.
70-
71-
1. Install the extension by using the following [Azure Functions Core Tools CLI](../../functions-run-local.md#install-the-azure-functions-core-tools) command:
65+
Install the latest version of the [Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged](https://www.nuget.org/packages/Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged) package by using the [dotnet add package](/dotnet/core/tools/dotnet-add-package) command:
7266

7367
```cmd
74-
func extensions install --package Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged
68+
dotnet add package Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged --prerelease
7569
```
7670

7771
::: zone-end
7872

7973
::: zone pivot="other"
8074

81-
## Specify the required extension bundles
75+
Until the durable task scheduler package is added to the extension bundles, you need to manually install the latest version of these packages using [Azure Functions Core Tools](../../functions-run-local.md#install-the-azure-functions-core-tools):
76+
- [Microsoft.Azure.WebJobs.Extensions.DurableTask.AzureManaged](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask.AzureManaged/)
77+
- [Microsoft.Azure.WebJobs.Extensions.DurableTask](https://www.nuget.org/packages/Microsoft.Azure.WebJobs.Extensions.DurableTask)
8278

83-
Update the `extensionBundle` property to use the preview version that contains the DTS package:
79+
For example:
80+
```cmd
81+
func extensions install --package Microsoft.Azure.WebJobs.Extensions.DurableTask.AzureManaged --version 0.4.2-alpha
82+
```
83+
```cmd
84+
func extensions install --package Microsoft.Azure.WebJobs.Extensions.DurableTask --version 3.0.4
85+
```
8486

85-
```json
86-
{
87-
"extensionBundle": {
88-
"id": "Microsoft.Azure.Functions.ExtensionBundle.Preview",
89-
"version": "[4.*, 5.0.0)"
90-
}
91-
}
87+
These commands should automatically generate a *extensions.csproj* file that looks like the following to your app. If the package references are not added to the file, check to ensure that `net8.0` is the target framework and run the commands again:
88+
89+
```xml
90+
<Project Sdk="Microsoft.NET.Sdk">
91+
<PropertyGroup>
92+
<TargetFramework>net8.0</TargetFramework>
93+
<WarningsAsErrors></WarningsAsErrors>
94+
<DefaultItemExcludes>**</DefaultItemExcludes>
95+
</PropertyGroup>
96+
<ItemGroup>
97+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="3.0.4" />
98+
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask.AzureManaged" Version="0.4.2-alpha" />
99+
<PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.1.3" />
100+
</ItemGroup>
101+
</Project>
92102
```
93103

104+
> [!NOTE]
105+
> Remember to remove the reference to extension bundles in `host.json`.
106+
94107
::: zone-end
95108

96109
## Update host.json
@@ -129,31 +142,32 @@ Add connection information for local development:
129142

130143
Get the DTS emulator port number in [the next step](#set-up-dts-emulator).
131144

132-
> [!NOTE]
133-
> For local development, it's easiest to use the `default` task hub. Setting up other task hubs require extra configuration.
134-
135145
## Set up DTS emulator
136146

137147
1. Pull the docker image containing the emulator.
138148

139149
```bash
140-
docker pull mcr.microsoft.com/dts/dts-emulator:v0.0.4
150+
docker pull mcr.microsoft.com/dts/dts-emulator:v0.0.5
141151
```
142152

143153
1. Run the emulator.
144154

145155
```bash
146-
docker run -itP mcr.microsoft.com/dts/dts-emulator:v0.0.4
156+
docker run -itP mcr.microsoft.com/dts/dts-emulator:v0.0.5
147157
```
148158

159+
The command above registers the default task hub. If you need more than one task hub, you can set the environment variable `DTS_TASK_HUB_NAMES` on the container to a comma-delimited list of task hub names like below:
160+
161+
```bash
162+
docker run -itP -e DTS_TASK_HUB_NAMES=taskhub1,taskhub2,taskhub3 mcr.microsoft.com/dts/dts-emulator:v0.0.5
163+
```
164+
149165
The following indicates the emulator started successfully.
150166
:::image type="content" source="media/quickstart-durable-task-scheduler/emulator-started.png" alt-text="Screenshot showing emulator started successfully on terminal.":::
151167

152-
1. Make note of the three ports exposed on Docker desktop: `8080`, `8081`, and `8082`.
168+
1. Make note of the ports exposed on Docker desktop. These static ports are exposed by the container and mapped dynamically by default. DTS exposes multiple ports for different purposes:
153169

154-
These static ports are exposed by the container and mapped dynamically by default. DTS exposes multiple ports for different purposes:
155170
- `8080`: gRPC endpoint that allows an app to connect to DTS
156-
- `8081`: Endpiont for metrics gathering
157171
- `8082`: Endpoint for DTS dashboard
158172

159173
:::image type="content" source="media/quickstart-durable-task-scheduler/docker-ports.png" alt-text="Screenshot of ports on Docker.":::
@@ -220,13 +234,28 @@ Create a DTS instance and Azure Functions app on Azure following the *Function a
220234

221235
[!INCLUDE [function-app-integrated-creation](./includes/function-app-integrated-creation.md)]
222236

237+
### Add required environment variables to app
238+
239+
Add the following environment variables:
240+
- `TASKHUB_NAME`: name of task hub
241+
- `DURABLE_TASK_SCHEDULER_CONNECTION_STRING`: the format of the string is `"Endpoint={DTS endpoint};Authentication=ManagedIdentity;ClientID={client id}"`, where *endpoint* is the DTS endpoint and *client id* is the managed identity client ID.
242+
243+
You can use this command:
244+
```azurecli
245+
az functionapp config appsettings set --resource-group RESOURCE_GROUP_NAME --name FUNCTION_APP_NAME --settings KEY_NAME=KEY_VALUE
246+
```
247+
223248
### Deploy your function app to Azure
224249

225250
[!INCLUDE [functions-publish-project-vscode](../../../../includes/functions-deploy-project-vs-code.md)]
226251

227252
#### Apps on Functions Premium plan
228253

229-
If your app is running on the Functions Premium plan, follow instructions to [turn on Runtime Scale Monitoring](./develop-with-durable-task-scheduler.md#auto-scaling-in-functions-premium-plan) after deployment. This ensures your app autoscales based on load.
254+
If your app is running on the Functions Premium plan, turn on the *Runtime Scale Monitoring* setting after deployment to ensure your app autoscales based on load:
255+
256+
```azurecli
257+
az resource update -g <resource_group> -n <function_app_name>/config/web --set properties.functionsRuntimeScaleMonitoringEnabled=1 --resource-type Microsoft.Web/sites
258+
```
230259

231260
## Test your function app
232261

@@ -238,10 +267,12 @@ az functionapp function list --resource-group <RESOURCE_GROUP_NAME> --name <FUNC
238267

239268
### Check orchestration status
240269

241-
Check the status of the orchestration instance and activity details on the DTS dashboard.
270+
Check the status of the orchestration instance and activity details on the DTS dashboard. Follow the instructions below to assign the required role to your developer identity (email) to get access to the dashboard.
242271

243272
[!INCLUDE [assign-dev-identity-rbac-portal](./includes/assign-dev-identity-rbac-portal.md)]
244273

274+
Finally, navigate to `https://dashboard.durabletask.io/` and click on **Add Endpoint**. Fill out the required fields to connect the task hub.
275+
245276
## Clean up resources
246277

247278
If you no longer need the resources that you created to complete the quickstart, to avoid related costs in your Azure subscription, [delete the resource group](/azure/azure-resource-manager/management/delete-resource-group?tabs=azure-portal#delete-resource-group) and all related resources.

0 commit comments

Comments
 (0)