Skip to content

Commit a217584

Browse files
author
Seth
committed
Merge branch 'main' into app-sample-end-to-end
2 parents a6cd084 + b33d303 commit a217584

26 files changed

+549
-60
lines changed

.devcontainer/devcontainer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"image": "mcr.microsoft.com/devcontainers/python:3.10-bullseye",
55
"features": {
66
// See https://containers.dev/features for list of features
7-
"ghcr.io/devcontainers/features/docker-in-docker:2": {
8-
},
9-
"ghcr.io/azure/azure-dev/azd:latest": {}
7+
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
8+
"ghcr.io/azure/azure-dev/azd:latest": {},
9+
"ghcr.io/devcontainers/features/azure-cli:1": {}
1010
}
1111
}

.github/workflows/azure-dev.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,19 @@ jobs:
2525
uses: actions/checkout@v4
2626
- name: Install azd
2727
uses: Azure/setup-azd@v2
28-
- name: Log in with Azure (Federated Credentials)
28+
- name: Azure Developer CLI Login
2929
run: |
3030
azd auth login `
3131
--client-id "$Env:AZURE_CLIENT_ID" `
3232
--federated-credential-provider "github" `
3333
--tenant-id "$Env:AZURE_TENANT_ID"
3434
shell: pwsh
35-
35+
- name: Azure CLI Login
36+
uses: azure/login@v2
37+
with:
38+
client-id: ${{ vars.AZURE_CLIENT_ID }}
39+
tenant-id: ${{ vars.AZURE_TENANT_ID }}
40+
subscription-id: ${{ vars.AZURE_SUBSCRIPTION_ID }}
3641
- name: Provision Infrastructure
3742
run: azd provision --no-prompt
3843
env:

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.vscode
22
.vs
3-
.venv
3+
.venv
4+
__pycache__

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Offers ability to [start with an existing Azure AI Project](docs/transfer_projec
4747
1. Have access to an Azure subscription and Entra ID account with Contributor permissions.
4848
2. Confirm the subscription you are deploying into has the [Required Roles and Scopes](docs/Required_roles_scopes_resources.md).
4949
3. The solution ensures secure access to the private VNET through a jump-box VM with Azure Bastion. By default, Bastion does not require an inbound NSG rule for network traffic. However, if your environment enforces specific policy rules, you can resolve access issues by entering your machine's IP address in the `allowedIpAddress` parameter when prompted during deployment. If not specified, all IP addresses are allowed to connect to Azure Bastion.
50-
4. If deploying from your [local environment](docs/local_environment_steps.md), install the [Azure Developer CLI (AZD)](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux&pivots=os-windows).
50+
4. If deploying from your [local environment](docs/local_environment_steps.md), install the [Azure CLI (AZ)](https://learn.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest) and the [Azure Developer CLI (AZD)](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/install-azd?tabs=winget-windows%2Cbrew-mac%2Cscript-linux&pivots=os-windows).
5151
5. If deploying via [GitHub Codespaces](docs/github_code_spaces_steps.md) - requires the user to be on a GitHub Team or Enterprise Cloud plan.
5252
6. If leveraging [One-click deployment](#quick-deploy).
5353
7. If leveraging [GitHub Actions](docs/github_actions_steps.md).

azure.yaml

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,30 +5,24 @@ metadata:
55
template: deploy-your-ai-application-in-production@1.0
66
hooks:
77
preup:
8-
windows:
9-
shell: pwsh
10-
run: ./scripts/SetConnectionsEnvironmentVariables.ps1
11-
interactive: true
12-
continueOnError: false
8+
windows:
9+
shell: pwsh
10+
run: ./scripts/set_conns_env_vars.ps1
11+
interactive: true
12+
continueOnError: false
13+
posix:
14+
shell: sh
15+
run: chmod u+r+x ./scripts/set_conns_env_vars.sh; ./scripts/set_conns_env_vars.sh
16+
interactive: true
17+
continueOnError: false
1318
preprovision:
14-
windows:
15-
shell: pwsh
16-
run: ./scripts/auth_init.ps1
17-
interactive: true
18-
continueOnError: false
19-
posix:
20-
shell: sh
21-
run: chmod u+r+x ./scripts/auth_init.sh; ./scripts/auth_init.sh
22-
interactive: true
23-
continueOnError: false
24-
postprovision:
25-
windows:
26-
shell: pwsh
27-
run: ./scripts/auth_update.ps1;
28-
interactive: true
29-
continueOnError: false
30-
posix:
31-
shell: sh
32-
run: chmod u+r+x ./scripts/auth_update.sh; ./scripts/auth_update.sh
33-
interactive: true
34-
continueOnError: false
19+
posix:
20+
shell: sh
21+
run: chmod u+r+x ./scripts/validate_model_deployment_quotas.sh; chmod u+r+x ./scripts/validate_model_quota.sh; ./scripts/validate_model_deployment_quotas.sh --subscription $AZURE_SUBSCRIPTION_ID --location $AZURE_LOCATION --models-parameter "aiModelDeployments"
22+
interactive: false
23+
continueOnError: false
24+
windows:
25+
shell: pwsh
26+
run: ./scripts/validate_model_deployment_quotas.ps1 -Subscription $env:AZURE_SUBSCRIPTION_ID -Location $env:AZURE_LOCATION -ModelsParameter "aiModelDeployments"
27+
interactive: false
28+
continueOnError: false

docs/Verify_Services_On_Network.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ This guide will walk you through using a secure jump-box virtual machine to inst
66

77
### 1. Copy Testing Script to Virtual Machine
88

9-
Copy [TestConnections.ps1](./scripts/TestConnections.ps1) to the Virtual Machine.
9+
Copy [test_azure_resource_conns.ps1](./scripts/test_azure_resource_conns.ps1) to the Virtual Machine.
1010

1111
### 2. Install Azure CLI
1212

@@ -41,7 +41,7 @@ $containerRegistry = "your-container-registry-name"
4141
### 5. Execute Testing PowerShell Script
4242

4343
```powershell
44-
.\TestConnections.ps1 `
44+
.\test_azure_resource_conns.ps1 `
4545
-SubscriptionId $subscriptionId `
4646
-ResourceGroup $resourceGroup `
4747
-KeyVault $keyvault `

docs/github_code_spaces_steps.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,31 +32,40 @@ You can run this solution using GitHub Codespaces. The button will open a web-ba
3232

3333
![Image showing the password prompt for azure](../img/provisioning/enterpassword.png)
3434

35-
**Prompting for MFA**
35+
7. Return to the codespaces window and type “az login”. The [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/what-is-azure-cli?view=azure-cli-latest) is used to validate available AI model quota.
36+
![image showing theaz login in the vs code terminal](../img/provisioning/az_login.png)
3637

37-
![Image showing the pop up window in the web browser for azd auth](../img/provisioning/azdauthpopup.png)
38-
39-
7. Return to the codespaces window now. In the terminal window, begin by initializing the environment by typing the command “azd init”
38+
8. Return to the codespaces window now. In the terminal window, begin by initializing the environment by typing the command “azd init”
4039

4140
![image showing the initial screen in the vs code terminal](../img/provisioning/azd_init_terminal.png)
4241

43-
8. Enter the name for your environment
42+
9. Enter the name for your environment
4443

4544
![aImage showing entering a new environment name](../img/provisioning/enter_evn_name.png)
4645

47-
9. Now start the deployment of the infrastructure by typing the command “azd provision”
46+
10. Now start the deployment of the infrastructure by typing the command “azd up”
47+
48+
![image showing the terminal in vs code](../img/provisioning/azd_provision_terminal.png)
49+
50+
This step will allow you to choose from the subscriptions you have available, based on the account you logged in with in the login step. Next it will prompt you for the region to deploy the resources into as well as any additional Azure resources to be provisioned and configured.
51+
52+
**Be sure to remember the vm password. This will be used in a later step. You are still required to log into Azure once you connect through the virtual machine.
53+
54+
55+
11. The automated model quota check will run, and will check if the location selected will have the necessary quota for the AI Models that are listed in the parameters file prior to deploying any resources.
56+
![image showing model quota pre-provision code executing](../img/provisioning/preprovision_output.png)
57+
58+
59+
If the location selected has sufficient quota for the models you plan to deploy, the provisioning will begin without notification.
4860

49-
![image showing the terminal in vs code](../img/provisioning/azd_provision_terminal.png)
61+
![image showing model quota pre-provision pass](../img/provisioning/preprovision_success.png)
5062

51-
This step will allow you to choose from the subscriptions you have available, based on the account you logged in with in the azd auth login step. Next it will prompt you for the region to deploy the resources into.
63+
If the location selected does not have the available quota for the models selected in your parameters, there will be a message back to the user, prior to any provisioning of resources. This will allow the developer to change the location of the provisiong and try again. Note that in our example, Italy North had capacity for gpt-4o but not for text-embedding-ada-002. This terminated the entire provisioning, because both models could not be deployed due to a quota issue.
5264

53-
![image showing region selection](../img/provisioning/azdprovision_select_location.png)
65+
![image showing model quota pre-provision fail](../img/provisioning/preprovision_fail.png)
5466

55-
10. Next you will be prompted for values to enable additional features outside of the AI Foundry required features. They are false by default.
56-
![image of prompts](../img/provisioning/prompts.png)
57-
**Be sure to remember the vm password and vm username. This will be used in a later step. Because we are using FDPO subscriptions, we do not have access to Entra to create the SSO to the jump box at this time. You are still required to log into Azure once you connect to the virtual machine.
67+
12. After completeing the required paramters that you were prompted for, and a successful model quota validation, the provisioning of resources will run and deploy the Network Isolated AI Foundry development portal and dependent resources in about 20 minutes.
5868

59-
11. After completeing the required paramters that you were prompted for, the provisioning of resources will run and deploy the Network Isolated AI hub, project and dependent resources in about 20 minutes.
6069

6170
# Post Deployment Steps:
6271
These steps will help to check that the isolated environment was set up correctly.

docs/local_environment_steps.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ git clone https://github.com/microsoft/Deploy-Your-AI-Application-In-Production.
77
cd Deploy-Your-AI-Application-In-Production
88
```
99

10-
### Establish AZD Environment
10+
### Establish Environment
1111

12-
This solution uses the [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview) to quickly provision and deploy infrastructure and applications to Azure.
12+
This solution uses the [Azure CLI](https://learn.microsoft.com/en-us/cli/azure/what-is-azure-cli?view=azure-cli-latest) and the [Azure Developer CLI](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/overview) to quickly provision and deploy infrastructure and applications to Azure.
1313

1414
To get started, authenticate with an Azure Subscription ([details](https://learn.microsoft.com/en-us/azure/developer/azure-developer-cli/reference#azd-auth-login)):
1515

1616
```powershell
1717
azd auth login
1818
```
1919

20+
Also authenticate with the Azure CLI ([details](https://learn.microsoft.com/en-us/cli/azure/authenticate-azure-cli?view=azure-cli-latest)):
21+
22+
```powershell
23+
az login
24+
```
25+
2026
Establish a new environment. Provide a name that represents the application domain:
2127

2228
```powershell

docs/quota_check.md

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Before deploying the accelerator, **ensure sufficient quota availability** for t
55
66
## Login if you have not done so already
77
```
8-
azd auth login
8+
az login
99
```
1010

1111
## 📌 Default Models & Capacities:
@@ -88,12 +88,4 @@ The final table lists regions with available quota. You can select any of these
8888
```sh
8989
./quota_check.sh
9090
```
91-
- Refer to [Input Formats](#input-formats) for detailed commands.
92-
93-
5. If you see the error `_bash: az: command not found_`, install Azure CLI:
94-
95-
```sh
96-
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
97-
az login
98-
```
99-
6. Rerun the script after installing Azure CLI.
91+
- Refer to [Input Formats](#input-formats) for detailed commands.

img/provisioning/az_login.png

16.2 KB
Loading
-15.8 KB
Loading
-2.73 KB
Loading
8.73 KB
Loading
250 Bytes
Loading
-740 Bytes
Loading

img/provisioning/enterpassword.png

-1.17 KB
Loading
55.1 KB
Loading
51.8 KB
Loading
21.8 KB
Loading

scripts/set_conns_env_vars.sh

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
#!/bin/bash
2+
3+
# Usage: ./set_conns_env_vars.sh [--tenant TENANT] [--subscription SUBSCRIPTION] [--resource-group RESOURCE_GROUP] [--workspace WORKSPACE] [--include-verbose]
4+
5+
while [[ $# -gt 0 ]]; do
6+
case "$1" in
7+
--tenant)
8+
TENANT="$2"
9+
shift 2
10+
;;
11+
--subscription)
12+
SUBSCRIPTION="$2"
13+
shift 2
14+
;;
15+
--resource-group)
16+
RESOURCE_GROUP="$2"
17+
shift 2
18+
;;
19+
--workspace)
20+
WORKSPACE="$2"
21+
shift 2
22+
;;
23+
--include-verbose)
24+
INCLUDE_VERBOSE=true
25+
shift
26+
;;
27+
*)
28+
echo "Unknown option: $1"
29+
exit 1
30+
;;
31+
esac
32+
done
33+
34+
TENANT="${TENANT:-$AZURE_ORIGINAL_TENANT_ID}"
35+
SUBSCRIPTION="${SUBSCRIPTION:-$AZURE_ORIGINAL_SUBSCRIPTION_ID}"
36+
RESOURCE_GROUP="${RESOURCE_GROUP:-$AZURE_ORIGINAL_RESOURCE_GROUP}"
37+
WORKSPACE="${WORKSPACE:-$AZURE_ORIGINAL_WORKSPACE_NAME}"
38+
39+
if [[ -z "$TENANT" || -z "$SUBSCRIPTION" || -z "$RESOURCE_GROUP" || -z "$WORKSPACE" ]]; then
40+
read -p "Start with existing Project connections? [NOTE: This action cannot be undone after executing. To revert, create a new AZD environment and run the process again.] (yes/no) " response
41+
if [[ "$response" == "yes" ]]; then
42+
[[ -z "$TENANT" ]] && read -p "Enter Tenant ID: " TENANT
43+
[[ -z "$SUBSCRIPTION" ]] && read -p "Enter Subscription ID: " SUBSCRIPTION
44+
[[ -z "$RESOURCE_GROUP" ]] && read -p "Enter Resource Group: " RESOURCE_GROUP
45+
[[ -z "$WORKSPACE" ]] && read -p "Enter Workspace / Project Name: " WORKSPACE
46+
else
47+
echo "Not starting with existing Project. Exiting script."
48+
exit 0
49+
fi
50+
else
51+
echo "All parameters provided. Starting with existing Project ${WORKSPACE}."
52+
fi
53+
54+
if [[ -z "$TENANT" || -z "$SUBSCRIPTION" || -z "$RESOURCE_GROUP" || -z "$WORKSPACE" ]]; then
55+
echo "Unable to start with existing Project: One or more required parameters are missing."
56+
exit 1
57+
fi
58+
59+
az account set --subscription "$SUBSCRIPTION"
60+
61+
TOKEN=$(az account get-access-token --resource https://management.azure.com --query accessToken -o tsv)
62+
if [[ -z "$TOKEN" ]]; then
63+
echo "Failed to get Azure access token."
64+
exit 1
65+
fi
66+
67+
CONNECTIONS_URL="https://management.azure.com/subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.MachineLearningServices/workspaces/$WORKSPACE/connections?api-version=2024-10-01"
68+
CONNECTIONS_RESPONSE=$(curl -s -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" "$CONNECTIONS_URL")
69+
CONNECTIONS=$(echo "$CONNECTIONS_RESPONSE" | jq '.value')
70+
71+
echo "Connections in workspace ${WORKSPACE}"
72+
echo "----------------------------------"
73+
CONNECTION_COUNT=$(echo "$CONNECTIONS" | jq 'length')
74+
echo "Connection count: $CONNECTION_COUNT"
75+
if [[ "$CONNECTION_COUNT" -eq 0 ]]; then
76+
echo "No connections found in the workspace."
77+
exit 0
78+
fi
79+
80+
if [[ "$INCLUDE_VERBOSE" == true ]]; then
81+
echo "Connections response:"
82+
echo "$CONNECTIONS"
83+
fi
84+
echo "----------------------------------"
85+
86+
COGSVC_URL="https://management.azure.com/subscriptions/$SUBSCRIPTION/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.CognitiveServices/accounts/?api-version=2023-05-01"
87+
COGSVC_RESPONSE=$(curl -s -H "Authorization: Bearer $TOKEN" -H "Content-Type: application/json" "$COGSVC_URL")
88+
COGSVC_ACCOUNTS=$(echo "$COGSVC_RESPONSE" | jq '.value')
89+
90+
echo "Cognitive Service Accounts in resource group ${RESOURCE_GROUP}"
91+
echo "----------------------------------"
92+
COGSVC_COUNT=$(echo "$COGSVC_ACCOUNTS" | jq 'length')
93+
echo "Cognitive Service Account count: $COGSVC_COUNT"
94+
if [[ "$COGSVC_COUNT" -eq 0 ]]; then
95+
echo "No Cognitive Service Accounts found in the resource group."
96+
exit 0
97+
fi
98+
99+
if [[ "$INCLUDE_VERBOSE" == true ]]; then
100+
echo "Cognitive Service Accounts response:"
101+
echo "$COGSVC_ACCOUNTS"
102+
fi
103+
104+
for i in $(seq 0 $(($COGSVC_COUNT - 1))); do
105+
ACCOUNT_NAME=$(echo "$COGSVC_ACCOUNTS" | jq -r ".[$i].name")
106+
NORMALIZED_ACCOUNT_NAME=$(echo "$ACCOUNT_NAME" | tr -d '-_')
107+
echo "Normalized Cognitive Service Account Name: $NORMALIZED_ACCOUNT_NAME"
108+
done
109+
echo "----------------------------------"
110+
111+
echo "Connections details:"
112+
echo "----------------------------------"
113+
for i in $(seq 0 $(($CONNECTION_COUNT - 1))); do
114+
NAME=$(echo "$CONNECTIONS" | jq -r ".[$i].name")
115+
AUTHTYPE=$(echo "$CONNECTIONS" | jq -r ".[$i].properties.authType")
116+
CATEGORY=$(echo "$CONNECTIONS" | jq -r ".[$i].properties.category")
117+
TARGET=$(echo "$CONNECTIONS" | jq -r ".[$i].properties.target")
118+
119+
echo "Name: $NAME"
120+
echo "AuthType: $AUTHTYPE"
121+
echo "Category: $CATEGORY"
122+
echo "Target: $TARGET"
123+
124+
if [[ "$CATEGORY" == "CognitiveSearch" ]]; then
125+
azd env set 'AZURE_AI_SEARCH_ENABLED' 'true'
126+
echo "Environment variable AZURE_AI_SEARCH_ENABLED set to true"
127+
fi
128+
129+
if [[ "$CATEGORY" == "CognitiveService" ]]; then
130+
for j in $(seq 0 $(($COGSVC_COUNT - 1))); do
131+
ACCOUNT_NAME=$(echo "$COGSVC_ACCOUNTS" | jq -r ".[$j].name")
132+
NORMALIZED_ACCOUNT_NAME=$(echo "$ACCOUNT_NAME" | tr -d '-_')
133+
if [[ "$NORMALIZED_ACCOUNT_NAME" == "$NAME" ]]; then
134+
RESOURCE_NAME="$ACCOUNT_NAME"
135+
KIND=$(echo "$COGSVC_ACCOUNTS" | jq -r ".[$j].kind")
136+
echo "Matched Cognitive Service Account - Connection: '$NAME' Resource: $RESOURCE_NAME"
137+
case "$KIND" in
138+
ContentSafety)
139+
azd env set 'AZURE_AI_CONTENT_SAFETY_ENABLED' 'true'
140+
echo "Environment variable AZURE_AI_CONTENT_SAFETY_ENABLED set to true"
141+
;;
142+
SpeechServices)
143+
azd env set 'AZURE_AI_SPEECH_ENABLED' 'true'
144+
echo "Environment variable AZURE_AI_SPEECH_ENABLED set to true"
145+
;;
146+
FormRecognizer)
147+
azd env set 'AZURE_AI_DOC_INTELLIGENCE_ENABLED' 'true'
148+
echo "Environment variable AZURE_AI_DOC_INTELLIGENCE_ENABLED set to true"
149+
;;
150+
ComputerVision)
151+
azd env set 'AZURE_AI_VISION_ENABLED' 'true'
152+
echo "Environment variable AZURE_AI_VISION_ENABLED set to true"
153+
;;
154+
TextAnalytics)
155+
azd env set 'AZURE_AI_LANGUAGE_ENABLED' 'true'
156+
echo "Environment variable AZURE_AI_LANGUAGE_ENABLED set to true"
157+
;;
158+
TextTranslation)
159+
azd env set 'AZURE_AI_TRANSLATOR_ENABLED' 'true'
160+
echo "Environment variable AZURE_AI_TRANSLATOR_ENABLED set to true"
161+
;;
162+
*)
163+
echo "Unknown resource kind: $KIND"
164+
;;
165+
esac
166+
fi
167+
done
168+
fi
169+
echo "-------------------------"
170+
done
171+
echo "----------------------------------"
File renamed without changes.

0 commit comments

Comments
 (0)