Skip to content

Commit 2b40191

Browse files
authored
Updates (#256)
Updates to readme and new delete script
1 parent db5361e commit 2b40191

File tree

2 files changed

+96
-3
lines changed

2 files changed

+96
-3
lines changed

samples/microsoft/infrastructure-setup/15-private-network-standard-agent-setup/README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,15 +77,21 @@ This implementation gives you full control over the inbound and outbound communi
7777
1. Review network requirements and plan Virtual Network address space (e.g., 192.168.0.0/16 or an alternative non-overlapping address space)
7878

7979
2. Two subnets are needed as well:
80-
- **Agent Subnet** (e.g., 192.168.0.0/24): Hosts Agent client for Agent workloads
80+
- **Agent Subnet** (e.g., 192.168.0.0/24): Hosts Agent client for Agent workloads, delegated to Microsoft.App/environments
8181
- **Private endpoint Subnet** (e.g. 192.168.1.0/24): Hosts private endpoints
82-
- Ensure that the address spaces for these subnets do not overlap with any existing networks in your Azure environment
82+
- Ensure that the address spaces for these subnets do not overlap with any existing networks in your Azure environment or reserved IP ranges like the following: 169.254.0.0/16, 172.30.0.0/16, 172.31.0.0/16, 192.0.2.0/24, 0.0.0.0/8, 127.0.0.0/8, 100.100.0.0/17, 100.100.192.0/19, 100.100.224.0/19, 10.0.0.0/8.
8383

84-
> **Note:** If you do not provide an existing virtual network, the template will create a new virtual network with the default address spaces and subnets described above. If you use an existing virtual network, make sure it already contains two subnets (Agent and Private Endpoint) before deploying the template.
84+
> **Notes:**
85+
- If you do not provide an existing virtual network, the template will create a new virtual network with the default address spaces and subnets described above. If you use an existing virtual network, make sure it already contains two subnets (Agent and Private Endpoint) before deploying the template.
86+
- You must ensure the Foundry account was successfully created so that underlying caphost has also succeeded. Then proceed to deploying the project caphost bicep.
87+
- You must ensure the subnet is not already in use by another account. It must be an exclusive subnet for the Foundry account.
88+
- You must ensure the subnet is exclusively delegated to __Microsoft.App/environments__ and cannot be used by any other Azure resources.
8589

8690
**Limitations:**
8791
- Class A subnet support is only available in a limited number of regions and requires your subscription id be allowlisted. Please reach out to [email protected] if you are interested in getting access.
8892
- Supported regions: West US, East US, East US 2, Central US, Japan East, France Central, [New] Spain Central, [New] UAE North
93+
- The capability host sub-resources of Resource/Project must be deleted before deleting the Resource/Project resource itself. You can use the script __deleteCaphost.sh__ located in this folder to delete it.
94+
8995

9096
### Template Customization
9197

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
3+
# Script to delete the capability host
4+
5+
# Prompt for required information
6+
read -p "Enter Subscription ID: " subscription_id
7+
read -p "Enter Resource Group name: " resource_group
8+
read -p "Enter Hub or Project name: " workspace_name
9+
read -p "Enter CapabilityHost name: " caphost_name
10+
11+
# Get Azure access token
12+
echo "Getting Azure access token..."
13+
access_token=$(az account get-access-token --query accessToken -o tsv)
14+
15+
if [ -z "$access_token" ]; then
16+
echo "Error: Failed to get access token. Please make sure you're logged in with 'az login'"
17+
exit 1
18+
fi
19+
20+
# Construct the API URL
21+
api_url="https://management.azure.com/subscriptions/${subscription_id}/resourceGroups/${resource_group}/providers/Microsoft.CognitiveServices/accounts/${account_name}/capabilityHosts/${caphost_name}?api-version=2025-04-01-preview"
22+
23+
# Check if the curl command was successful
24+
if [ $? -ne 0 ]; then
25+
echo -e "\nError: Failed to send deletion request."
26+
rm -f "${response_headers}"
27+
exit 1
28+
fi
29+
30+
# Extract the Azure-AsyncOperation URL from the response headers
31+
operation_url=$(grep -i "Azure-AsyncOperation" "${response_headers}" | cut -d' ' -f2 | tr -d '\r')
32+
33+
if [ -z "${operation_url}" ]; then
34+
echo -e "\nError: Could not find operation URL in the response."
35+
cat "${response_headers}"
36+
rm -f "${response_headers}"
37+
exit 1
38+
fi
39+
40+
rm -f "${response_headers}"
41+
42+
echo -e "\nCapability host deletion request initiated."
43+
echo "Monitoring operation: ${operation_url}"
44+
45+
# Poll the operation URL until the operation completes
46+
status="Creating"
47+
while [ "${status}" = "Creating" ]; do
48+
echo "Checking operation status..."
49+
access_token=$(az account get-access-token --query accessToken -o tsv)
50+
# Get the operation status
51+
operation_response=$(curl -s \
52+
-H "Authorization: Bearer ${access_token}" \
53+
-H "Content-Type: application/json" \
54+
"${operation_url}")
55+
56+
# Check for transient errors
57+
error_code=$(echo "${operation_response}" | jq -r '.error.code // empty')
58+
if [ "${error_code}" = "TransientError" ]; then
59+
echo "Transient error encountered. Continuing to poll..."
60+
sleep 10
61+
continue
62+
fi
63+
# Extract the status from the response using jq
64+
status=$(echo "${operation_response}" | jq -r '.status')
65+
66+
if [ -z "${status}" ]; then
67+
echo "Error: Could not determine operation status."
68+
echo "Response: ${operation_response}"
69+
exit 1
70+
fi
71+
72+
echo "Current status: ${status}"
73+
74+
if [ "${status}" = "Creating" ]; then
75+
echo "Operation still in progress. Waiting 10 seconds before checking again..."
76+
sleep 10
77+
fi
78+
done
79+
80+
# Check the final status
81+
if [ "${status}" = "Succeeded" ]; then
82+
echo -e "\nCapability host deletion completed successfully."
83+
else
84+
echo -e "\nCapability host deletion failed with status: ${status}"
85+
echo "Response: ${operation_response}"
86+
exit 1
87+
fi

0 commit comments

Comments
 (0)