Skip to content

Commit 19b088b

Browse files
authored
Merge pull request #76 from Azure-Samples/feat/add-dts-dashboard-scripts
feat: add DTS dashboard URL generator scripts
2 parents b2f242d + c801eeb commit 19b088b

File tree

2 files changed

+99
-0
lines changed

2 files changed

+99
-0
lines changed

scripts/get-dts-dashboard-url.ps1

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#!/usr/bin/env pwsh
2+
3+
# Get subscription ID
4+
$subscriptionId = (az account show --query id -o tsv)
5+
6+
# Get tenant ID
7+
$tenantId = (az account show --query tenantId -o tsv)
8+
9+
# Get environment name from azd
10+
$envName = (azd env get-value AZURE_ENV_NAME)
11+
if (-not $envName) {
12+
Write-Error "Error: AZURE_ENV_NAME not found in azd environment"
13+
exit 1
14+
}
15+
16+
# Construct resource group name (follows azd naming convention)
17+
$resourceGroup = "rg-$envName"
18+
19+
# Get function app name from azd
20+
$functionName = (azd env get-value AZURE_FUNCTION_NAME)
21+
if (-not $functionName) {
22+
Write-Error "Error: AZURE_FUNCTION_NAME not found in azd environment"
23+
exit 1
24+
}
25+
26+
# Get DTS scheduler name
27+
$dtsName = (az resource list --resource-group $resourceGroup --resource-type "Microsoft.DurableTask/schedulers" --query "[0].name" -o tsv)
28+
if (-not $dtsName) {
29+
Write-Error "Error: No DTS scheduler found in resource group $resourceGroup"
30+
exit 1
31+
}
32+
33+
# Get DTS endpoint
34+
$dtsEndpoint = (az resource show --resource-group $resourceGroup --name $dtsName --resource-type "Microsoft.DurableTask/schedulers" --query "properties.endpoint" -o tsv)
35+
36+
# Get task hub name from function app settings
37+
$taskHubName = (az functionapp config appsettings list --name $functionName --resource-group $resourceGroup --query "[?name=='TASKHUB_NAME'].value" -o tsv)
38+
if (-not $taskHubName) {
39+
Write-Error "Error: TASKHUB_NAME not found in function app settings"
40+
exit 1
41+
}
42+
43+
# URL encode the endpoint
44+
$encodedEndpoint = [System.Web.HttpUtility]::UrlEncode($dtsEndpoint.Trim())
45+
46+
# Construct the full dashboard URL
47+
$dashboardUrl = "https://dashboard.durabletask.io/subscriptions/$subscriptionId/schedulers/$dtsName/taskhubs/${taskHubName}?endpoint=$encodedEndpoint&tenantId=$tenantId"
48+
49+
Write-Output $dashboardUrl

scripts/get-dts-dashboard-url.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Get subscription ID
5+
SUBSCRIPTION_ID=$(az account show --query id -o tsv)
6+
7+
# Get tenant ID
8+
TENANT_ID=$(az account show --query tenantId -o tsv)
9+
10+
# Get environment name from azd
11+
ENV_NAME=$(azd env get-value AZURE_ENV_NAME 2>/dev/null)
12+
if [ -z "$ENV_NAME" ]; then
13+
echo "Error: AZURE_ENV_NAME not found in azd environment" >&2
14+
exit 1
15+
fi
16+
17+
# Construct resource group name (follows azd naming convention)
18+
RESOURCE_GROUP="rg-${ENV_NAME}"
19+
20+
# Get function app name from azd
21+
FUNCTION_NAME=$(azd env get-value AZURE_FUNCTION_NAME 2>/dev/null)
22+
if [ -z "$FUNCTION_NAME" ]; then
23+
echo "Error: AZURE_FUNCTION_NAME not found in azd environment" >&2
24+
exit 1
25+
fi
26+
27+
# Get DTS scheduler name
28+
DTS_NAME=$(az resource list --resource-group "$RESOURCE_GROUP" --resource-type "Microsoft.DurableTask/schedulers" --query "[0].name" -o tsv)
29+
if [ -z "$DTS_NAME" ]; then
30+
echo "Error: No DTS scheduler found in resource group $RESOURCE_GROUP" >&2
31+
exit 1
32+
fi
33+
34+
# Get DTS endpoint
35+
DTS_ENDPOINT=$(az resource show --resource-group "$RESOURCE_GROUP" --name "$DTS_NAME" --resource-type "Microsoft.DurableTask/schedulers" --query "properties.endpoint" -o tsv)
36+
37+
# Get task hub name from function app settings
38+
TASKHUB_NAME=$(az functionapp config appsettings list --name "$FUNCTION_NAME" --resource-group "$RESOURCE_GROUP" --query "[?name=='TASKHUB_NAME'].value" -o tsv)
39+
if [ -z "$TASKHUB_NAME" ]; then
40+
echo "Error: TASKHUB_NAME not found in function app settings" >&2
41+
exit 1
42+
fi
43+
44+
# URL encode the endpoint (remove any trailing newlines first)
45+
ENCODED_ENDPOINT=$(echo -n $DTS_ENDPOINT | jq -sRr @uri)
46+
47+
# Construct the full dashboard URL
48+
DASHBOARD_URL="https://dashboard.durabletask.io/subscriptions/${SUBSCRIPTION_ID}/schedulers/${DTS_NAME}/taskhubs/${TASKHUB_NAME}?endpoint=${ENCODED_ENDPOINT}&tenantId=${TENANT_ID}"
49+
50+
echo $DASHBOARD_URL

0 commit comments

Comments
 (0)