Skip to content

Commit 9bdfe4f

Browse files
Add APIM resource private endpoint (#285)
* apim resource * made arm changes * fix variable * fix template * revert unnecesary changes * Fix high priority issues: parameter consistency and README documentation - Fixed parameter inconsistency between Bicep and JSON templates - Replaced separate apiManagementName, apiManagementResourceGroupName, apiManagementSubscriptionId parameters with single apiManagementResourceId parameter - Updated README.md with comprehensive API Management documentation - Added API Management to template customization section - Added API Management to private endpoints documentation - Added API Management to Private DNS Zones table - Maintains consistency with other resource parameter patterns * new folder for apim preview * Update README.md --------- Co-authored-by: vtomar <[email protected]>
1 parent 0c2d554 commit 9bdfe4f

23 files changed

+5181
-0
lines changed

samples/microsoft/infrastructure-setup/16-private-network-standard-agent-apim-setup-preview/README.md

Lines changed: 370 additions & 0 deletions
Large diffs are not rendered by default.

samples/microsoft/infrastructure-setup/16-private-network-standard-agent-apim-setup-preview/azuredeploy.json

Lines changed: 2750 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"location": {
6+
"value": "eastus2"
7+
},
8+
"aiServices": {
9+
"value": ""
10+
},
11+
"modelName": {
12+
"value": ""
13+
},
14+
"modelFormat": {
15+
"value": ""
16+
},
17+
"modelVersion": {
18+
"value": ""
19+
},
20+
"modelSkuName": {
21+
"value": ""
22+
},
23+
"modelCapacity": {
24+
"value": 0
25+
},
26+
"deploymentTimestamp": {
27+
"value": ""
28+
},
29+
"firstProjectName": {
30+
"value": ""
31+
},
32+
"projectDescription": {
33+
"value": ""
34+
},
35+
"displayName": {
36+
"value": ""
37+
},
38+
"vnetName": {
39+
"value": ""
40+
},
41+
"agentSubnetName": {
42+
"value": ""
43+
},
44+
"peSubnetName": {
45+
"value": ""
46+
},
47+
"existingVnetResourceId": {
48+
"value": ""
49+
},
50+
"vnetAddressPrefix": {
51+
"value": ""
52+
},
53+
"agentSubnetPrefix": {
54+
"value": ""
55+
},
56+
"peSubnetPrefix": {
57+
"value": ""
58+
},
59+
"aiSearchResourceId": {
60+
"value": ""
61+
},
62+
"azureStorageAccountResourceId": {
63+
"value": ""
64+
},
65+
"azureCosmosDBAccountResourceId": {
66+
"value": ""
67+
},
68+
"projectCapHost": {
69+
"value": ""
70+
},
71+
"apiManagementResourceId": {
72+
"value": ""
73+
},
74+
"existingDnsZones": {
75+
"value": {
76+
"privatelink.services.ai.azure.com": "",
77+
"privatelink.openai.azure.com": "",
78+
"privatelink.cognitiveservices.azure.com": "",
79+
"privatelink.search.windows.net": "",
80+
"privatelink.blob.core.windows.net": "",
81+
"privatelink.documents.azure.com": "",
82+
"privatelink.azure-api.net": ""
83+
}
84+
}
85+
}
86+
}
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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 Foundry Account or Project name: " account_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+
echo "Deleting capability host: ${caphost_name}"
24+
echo "API URL: ${api_url}"
25+
26+
# Send DELETE request and capture headers
27+
echo "Sending DELETE request..."
28+
response_headers=$(mktemp)
29+
curl -X DELETE \
30+
-H "Authorization: Bearer ${access_token}" \
31+
-H "Content-Type: application/json" \
32+
-D "${response_headers}" \
33+
-s \
34+
"${api_url}"
35+
36+
# Check if the curl command was successful
37+
if [ $? -ne 0 ]; then
38+
echo -e "\nError: Failed to send deletion request."
39+
rm -f "${response_headers}"
40+
exit 1
41+
fi
42+
43+
# Extract the Azure-AsyncOperation URL from the response headers
44+
operation_url=$(grep -i "Azure-AsyncOperation" "${response_headers}" | cut -d' ' -f2 | tr -d '\r')
45+
46+
if [ -z "${operation_url}" ]; then
47+
echo -e "\nError: Could not find operation URL in the response."
48+
cat "${response_headers}"
49+
rm -f "${response_headers}"
50+
exit 1
51+
fi
52+
53+
rm -f "${response_headers}"
54+
55+
echo -e "\nCapability host deletion request initiated."
56+
echo "Monitoring operation: ${operation_url}"
57+
58+
# Poll the operation URL until the operation completes
59+
status="Creating"
60+
while [ "${status}" = "Creating" ]; do
61+
echo "Checking operation status..."
62+
access_token=$(az account get-access-token --query accessToken -o tsv)
63+
# Get the operation status
64+
operation_response=$(curl -s \
65+
-H "Authorization: Bearer ${access_token}" \
66+
-H "Content-Type: application/json" \
67+
"${operation_url}")
68+
69+
# Check for transient errors
70+
error_code=$(echo "${operation_response}" | jq -r '.error.code // empty')
71+
if [ "${error_code}" = "TransientError" ]; then
72+
echo "Transient error encountered. Continuing to poll..."
73+
sleep 10
74+
continue
75+
fi
76+
# Extract the status from the response using jq
77+
status=$(echo "${operation_response}" | jq -r '.status')
78+
79+
if [ -z "${status}" ]; then
80+
echo "Error: Could not determine operation status."
81+
echo "Response: ${operation_response}"
82+
exit 1
83+
fi
84+
85+
echo "Current status: ${status}"
86+
87+
if [ "${status}" = "Creating" ]; then
88+
echo "Operation still in progress. Waiting 10 seconds before checking again..."
89+
sleep 10
90+
fi
91+
done
92+
93+
# Check the final status
94+
if [ "${status}" = "Succeeded" ]; then
95+
echo -e "\nCapability host deletion completed successfully."
96+
else
97+
echo -e "\nCapability host deletion failed with status: ${status}"
98+
echo "Response: ${operation_response}"
99+
exit 1
100+
fi

0 commit comments

Comments
 (0)