@@ -24,11 +24,23 @@ enable_public_access() {
2424
2525 # Enable public access for Storage Account
2626 echo " Enabling public access for Storage Account: $storageAccount "
27- original_storage_public_access=$( az storage account show --name " $storageAccount " --resource-group " $resourceGroupName " --query " publicNetworkAccess" -o tsv)
28- original_storage_default_action=$( az storage account show --name " $storageAccount " --resource-group " $resourceGroupName " --query " networkRuleSet.defaultAction" -o tsv)
27+ original_storage_public_access=$( az storage account show \
28+ --name " $storageAccount " \
29+ --resource-group " $resourceGroupName " \
30+ --query " publicNetworkAccess" \
31+ -o tsv)
32+ original_storage_default_action=$( az storage account show \
33+ --name " $storageAccount " \
34+ --resource-group " $resourceGroupName " \
35+ --query " networkRuleSet.defaultAction" \
36+ -o tsv)
2937
3038 if [ " $original_storage_public_access " != " Enabled" ]; then
31- az storage account update --name " $storageAccount " --resource-group " $resourceGroupName " --public-network-access Enabled --output none
39+ az storage account update \
40+ --name " $storageAccount " \
41+ --resource-group " $resourceGroupName " \
42+ --public-network-access Enabled \
43+ --output none
3244 if [ $? -eq 0 ]; then
3345 echo " ✓ Storage Account public access enabled"
3446 else
@@ -42,7 +54,11 @@ enable_public_access() {
4254 # Also ensure the default network action allows access
4355 if [ " $original_storage_default_action " != " Allow" ]; then
4456 echo " Setting Storage Account network default action to Allow"
45- az storage account update --name " $storageAccount " --resource-group " $resourceGroupName " --default-action Allow --output none
57+ az storage account update \
58+ --name " $storageAccount " \
59+ --resource-group " $resourceGroupName " \
60+ --default-action Allow \
61+ --output none
4662 if [ $? -eq 0 ]; then
4763 echo " ✓ Storage Account network default action set to Allow"
4864 else
@@ -55,9 +71,17 @@ enable_public_access() {
5571
5672 # Enable public access for AI Search Service
5773 echo " Enabling public access for AI Search Service: $aiSearchName "
58- original_search_public_access=$( az search service show --name " $aiSearchName " --resource-group " $resourceGroupName " --query " publicNetworkAccess" -o tsv)
74+ original_search_public_access=$( az search service show \
75+ --name " $aiSearchName " \
76+ --resource-group " $resourceGroupName " \
77+ --query " publicNetworkAccess" \
78+ -o tsv)
5979 if [ " $original_search_public_access " != " Enabled" ]; then
60- az search service update --name " $aiSearchName " --resource-group " $resourceGroupName " --public-access enabled --output none
80+ az search service update \
81+ --name " $aiSearchName " \
82+ --resource-group " $resourceGroupName " \
83+ --public-access enabled \
84+ --output none
6185 if [ $? -eq 0 ]; then
6286 echo " ✓ AI Search Service public access enabled"
6387 else
@@ -75,21 +99,22 @@ enable_public_access() {
7599 # Extract resource group from the AI Foundry account resource ID
76100 aif_resource_group=$( echo " $aif_account_resource_id " | sed -n ' s|.*/resourceGroups/\([^/]*\)/.*|\1|p' )
77101
78- # # Validate that we extracted a resource group name
79- # if [ -z "$aif_resource_group" ]; then
80- # echo "⚠ Warning: Could not extract resource group from AI Foundry resource ID: $aif_resource_id"
81- # echo " Falling back to using the main resource group: $resourceGroupName"
82- # aif_resource_group="$resourceGroupName"
83- # fi
84-
85102 echo " Enabling public access for AI Foundry resource: $aif_resource_name (Resource Group: $aif_resource_group )"
86- original_foundry_public_access=$( az cognitiveservices account show --name " $aif_resource_name " --resource-group " $aif_resource_group " --query " properties.publicNetworkAccess" --output tsv)
103+ original_foundry_public_access=$( az cognitiveservices account show \
104+ --name " $aif_resource_name " \
105+ --resource-group " $aif_resource_group " \
106+ --query " properties.publicNetworkAccess" \
107+ --output tsv)
87108 if [ -z " $original_foundry_public_access " ] || [ " $original_foundry_public_access " = " null" ]; then
88109 echo " ⚠ Info: Could not retrieve AI Foundry network access status."
89110 echo " AI Foundry network access might be managed differently."
90111 elif [ " $original_foundry_public_access " != " Enabled" ]; then
91112 echo " Current AI Foundry public access: $original_foundry_public_access "
92- if MSYS_NO_PATHCONV=1 az resource update --ids " $aif_account_resource_id " --api-version 2024-10-01 --set properties.publicNetworkAccess=Enabled properties.apiProperties=" {}" --output none; then
113+ if MSYS_NO_PATHCONV=1 az resource update \
114+ --ids " $aif_account_resource_id " \
115+ --api-version 2024-10-01 \
116+ --set properties.publicNetworkAccess=Enabled properties.apiProperties=" {}" \
117+ --output none; then
93118 echo " ✓ AI Foundry public access enabled"
94119 else
95120 echo " ⚠ Warning: Failed to enable AI Foundry public access automatically."
@@ -118,7 +143,11 @@ restore_network_access() {
118143 " disabled" |" Disabled" ) restore_value=" Disabled" ;;
119144 * ) restore_value=" $original_storage_public_access " ;;
120145 esac
121- az storage account update --name " $storageAccount " --resource-group " $resourceGroupName " --public-network-access " $restore_value " --output none
146+ az storage account update \
147+ --name " $storageAccount " \
148+ --resource-group " $resourceGroupName " \
149+ --public-network-access " $restore_value " \
150+ --output none
122151 if [ $? -eq 0 ]; then
123152 echo " ✓ Storage Account access restored"
124153 else
@@ -131,7 +160,11 @@ restore_network_access() {
131160 # Restore Storage Account network default action
132161 if [ -n " $original_storage_default_action " ] && [ " $original_storage_default_action " != " Allow" ]; then
133162 echo " Restoring Storage Account network default action to: $original_storage_default_action "
134- az storage account update --name " $storageAccount " --resource-group " $resourceGroupName " --default-action " $original_storage_default_action " --output none
163+ az storage account update \
164+ --name " $storageAccount " \
165+ --resource-group " $resourceGroupName " \
166+ --default-action " $original_storage_default_action " \
167+ --output none
135168 if [ $? -eq 0 ]; then
136169 echo " ✓ Storage Account network default action restored"
137170 else
@@ -150,7 +183,11 @@ restore_network_access() {
150183 " Disabled" |" DISABLED" ) restore_value=" Disabled" ;;
151184 * ) restore_value=" $original_search_public_access " ;;
152185 esac
153- az search service update --name " $aiSearchName " --resource-group " $resourceGroupName " --public-access " $restore_value " --output none
186+ az search service update \
187+ --name " $aiSearchName " \
188+ --resource-group " $resourceGroupName " \
189+ --public-access " $restore_value " \
190+ --output none
154191 if [ $? -eq 0 ]; then
155192 echo " ✓ AI Search Service access restored"
156193 else
@@ -164,7 +201,11 @@ restore_network_access() {
164201 if [ -n " $original_foundry_public_access " ] && [ " $original_foundry_public_access " != " Enabled" ]; then
165202 echo " Restoring AI Foundry public access to: $original_foundry_public_access "
166203 # Try using the working approach to restore the original setting
167- if MSYS_NO_PATHCONV=1 az resource update --ids " $aif_account_resource_id " --api-version 2024-10-01 --set properties.publicNetworkAccess=" $original_foundry_public_access " properties.apiProperties=" {}" --output none 2> /dev/null; then
204+ if MSYS_NO_PATHCONV=1 az resource update \
205+ --ids " $aif_account_resource_id " \
206+ --api-version 2024-10-01 \
207+ --set properties.publicNetworkAccess=" $original_foundry_public_access " properties.apiProperties=" {}" \
208+ --output none 2> /dev/null; then
168209 echo " ✓ AI Foundry access restored"
169210 else
170211 echo " ⚠ Warning: Failed to restore AI Foundry access automatically."
0 commit comments