Skip to content

Commit 7290f29

Browse files
Merge pull request microsoft#379 from microsoft/psl-avmwafchanges
2 parents e2dd7b0 + 7a0b86b commit 7290f29

18 files changed

+181
-82
lines changed

.github/workflows/deploy-waf.yml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,15 @@ jobs:
109109
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
110110
--template-file infra/main.bicep \
111111
--parameters \
112-
environmentName=${{ env.SOLUTION_PREFIX }} \
113-
useWafAlignedArchitecture=true \
114-
aiDeploymentsLocation='${{ env.AZURE_LOCATION }}' \
112+
solutionName=${{ env.SOLUTION_PREFIX }} \
113+
location="${{ env.AZURE_LOCATION }}" \
114+
azureAiServiceLocation='${{ env.AZURE_LOCATION }}' \
115115
gptModelCapacity=5 \
116-
virtualMachineConfiguration='{"adminUsername": "adminuser", "adminPassword": "P@ssw0rd1234"}' \
117-
logAnalyticsWorkspaceConfiguration='{"existingWorkspaceResourceId": ""}'
118-
116+
enableTelemetry=true \
117+
enableMonitoring=true \
118+
enablePrivateNetworking=true \
119+
enableScalability=true \
120+
119121
120122
- name: Send Notification on Failure
121123
if: failure()

.github/workflows/deploy.yml

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,19 +129,14 @@ jobs:
129129
--resource-group ${{ env.RESOURCE_GROUP_NAME }} \
130130
--template-file infra/main.bicep \
131131
--parameters \
132-
environmentName=${{ env.SOLUTION_PREFIX }} \
133-
solutionLocation="${{ env.AZURE_LOCATION }}" \
134-
modelDeploymentType="GlobalStandard" \
132+
solutionName=${{ env.SOLUTION_PREFIX }} \
133+
location="${{ env.AZURE_LOCATION }}" \
134+
gptModelDeploymentType="GlobalStandard" \
135135
gptModelName="gpt-4o" \
136136
gptModelVersion="2024-08-06" \
137137
imageTag="${IMAGE_TAG}" \
138-
useWafAlignedArchitecture=false \
139-
aiDeploymentsLocation='${{ env.AZURE_LOCATION }}' \
138+
azureAiServiceLocation='${{ env.AZURE_LOCATION }}' \
140139
gptModelCapacity=150 \
141-
logAnalyticsWorkspaceConfiguration='{"dataRetentionInDays": 30, "existingWorkspaceResourceId": ""}' \
142-
applicationInsightsConfiguration='{"retentionInDays": 30}' \
143-
virtualNetworkConfiguration='{"enabled": false}' \
144-
webServerFarmConfiguration='{"skuCapacity": 1, "skuName": "B2"}' \
145140
--output json
146141
147142
- name: Extract Web App and API App URLs

docs/DeploymentGuide.md

Lines changed: 12 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,8 @@ When you start the deployment, most parameters will have **default values**, but
153153
| **GPT Model Capacity** | Sets the GPT model capacity. | 150 |
154154
| **Image Tag** | Docker image tag used for container deployments. | latest |
155155
| **Enable Telemetry** | Enables telemetry for monitoring and diagnostics. | true |
156-
156+
| **Existing Log Analytics Workspace** | To reuse an existing Log Analytics Workspace ID instead of creating a new one. | *(none)* |
157+
| **Existing Azure AI Foundry Project** | To reuse an existing Azure AI Foundry Project ID instead of creating a new one. | *(none)* |
157158

158159
</details>
159160

@@ -176,6 +177,14 @@ To adjust quota settings, follow these [steps](./AzureGPTQuotaSettings.md).
176177

177178
</details>
178179

180+
<details>
181+
182+
<summary><b>Reusing an Existing Azure AI Foundry Project</b></summary>
183+
184+
Guide to get your [Existing Project ID](/docs/re-use-foundry-project.md)
185+
186+
</details>
187+
179188
### Deploying with AZD
180189

181190
Once you've opened the project in [Codespaces](#github-codespaces), [Dev Containers](#vs-code-dev-containers), or [locally](#local-environment), you can deploy it to Azure by following these steps:
@@ -206,43 +215,9 @@ Once you've opened the project in [Codespaces](#github-codespaces), [Dev Contain
206215

207216
5. Once the deployment has completed successfully, open the [Azure Portal](https://portal.azure.com/), go to the deployed resource group, find the App Service, and get the app URL from `Default domain`.
208217

209-
6. If you are done trying out the application, you can delete the resources by running `azd down`.
210-
211-
### Publishing Local Build Container to Azure Container Registry
212-
213-
If you need to rebuild the source code and push the updated container to the deployed Azure Container Registry, follow these steps:
214-
215-
1. Set the environment variable `USE_LOCAL_BUILD` to `True`:
216-
217-
- **Linux/macOS**:
218-
219-
```bash
220-
export USE_LOCAL_BUILD=True
221-
```
222-
223-
- **Windows (PowerShell)**:
224-
```powershell
225-
$env:USE_LOCAL_BUILD = $true
226-
```
227-
228-
2. Run the `az login` command
229-
230-
```bash
231-
az login
232-
```
233-
234-
3. Run the `azd up` command again to rebuild and push the updated container:
235-
```bash
236-
azd up
237-
```
238-
239-
This will rebuild the source code, package it into a container, and push it to the Azure Container Registry associated with your deployment.
240-
241-
This guide provides step-by-step instructions for deploying your application using Azure Container Registry (ACR) and Azure Container Apps.
242-
243-
There are several ways to deploy the solution. You can deploy to run in Azure in one click, or manually, or you can deploy locally.
218+
6. When Deployment is complete, follow steps in [Set Up Authentication in Azure App Service](../docs/azure_app_service_auth_setup.md) to add app authentication to your web app running on Azure App Service
244219

245-
When Deployment is complete, follow steps in [Set Up Authentication in Azure App Service](../docs/azure_app_service_auth_setup.md) to add app authentication to your web app running on Azure App Service
220+
7. If you are done trying out the application, you can delete the resources by running `azd down`.
246221

247222
# Local setup
248223

331 KB
Loading
94.9 KB
Loading
196 KB
Loading

docs/re-use-foundry-project.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
[← Back to *DEPLOYMENT* guide](/docs/DeploymentGuide.md#deployment-steps)
2+
3+
# Reusing an Existing Azure AI Foundry Project
4+
To configure your environment to use an existing Azure AI Foundry Project, follow these steps:
5+
---
6+
### 1. Go to Azure Portal
7+
Go to https://portal.azure.com
8+
9+
### 2. Search for Azure AI Foundry
10+
In the search bar at the top, type "Azure AI Foundry" and click on it. Then select the Foundry service instance where your project exists.
11+
12+
![alt text](../docs/images/re_use_foundry_project/azure_ai_foundry_list.png)
13+
14+
### 3. Navigate to Projects under Resource Management
15+
On the left sidebar of the Foundry service blade:
16+
17+
- Expand the Resource Management section
18+
- Click on Projects (this refers to the active Foundry project tied to the service)
19+
20+
### 4. Click on the Project
21+
From the Projects view: Click on the project name to open its details
22+
23+
Note: You will see only one project listed here, as each Foundry service maps to a single project in this accelerator
24+
25+
![alt text](../docs/images/re_use_foundry_project/navigate_to_projects.png)
26+
27+
### 5. Copy Resource ID
28+
In the left-hand menu of the project blade:
29+
30+
- Click on Properties under Resource Management
31+
- Locate the Resource ID field
32+
- Click on the copy icon next to the Resource ID value
33+
34+
![alt text](../docs/images/re_use_foundry_project/project_resource_id.png)
35+
36+
### 6. Set the Foundry Project Resource ID in Your Environment
37+
Run the following command in your terminal
38+
```bash
39+
azd env set AZURE_ENV_FOUNDRY_PROJECT_ID '<Existing Foundry Project Resource ID>'
40+
```
41+
Replace `<Existing Foundry Project Resource ID>` with the value obtained from Step 5.
42+
43+
### 7. Continue Deployment
44+
Proceed with the next steps in the [deployment guide](/docs/DeploymentGuide.md#deployment-steps).

docs/re-use-log-analytics.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
[← Back to *DEPLOYMENT* guide](/docs/DeploymentGuide.md#deployment-options--steps)
1+
[← Back to *DEPLOYMENT* guide](/docs/DeploymentGuide.md#deployment-steps)
22

33
# Reusing an Existing Log Analytics Workspace
44
To configure your environment to use an existing Log Analytics Workspace, follow these steps:
@@ -28,4 +28,4 @@ azd env set AZURE_ENV_LOG_ANALYTICS_WORKSPACE_ID '<Existing Log Analytics Worksp
2828
Replace `<Existing Log Analytics Workspace Id>` with the value obtained from Step 3.
2929

3030
### 5. Continue Deployment
31-
Proceed with the next steps in the [deployment guide](/docs/DeploymentGuide.md#deployment-options--steps).
31+
Proceed with the next steps in the [deployment guide](/docs/DeploymentGuide.md#deployment-steps).

infra/main.bicep

Lines changed: 48 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ param solutionName string = 'macae'
1717
param solutionUniqueText string = take(uniqueString(subscription().id, resourceGroup().name, solutionName), 5)
1818

1919
@metadata({ azd: { type: 'location' } })
20-
@description('Optional. Azure region for all services. Regions are restricted to guarantee compatibility with paired regions and replica locations for data redundancy and failover scenarios based on articles [Azure regions list](https://learn.microsoft.com/azure/reliability/regions-list) and [Azure Database for MySQL Flexible Server - Azure Regions](https://learn.microsoft.com/azure/mysql/flexible-server/overview#azure-regions).')
20+
@description('Required. Azure region for all services. Regions are restricted to guarantee compatibility with paired regions and replica locations for data redundancy and failover scenarios based on articles [Azure regions list](https://learn.microsoft.com/azure/reliability/regions-list) and [Azure Database for MySQL Flexible Server - Azure Regions](https://learn.microsoft.com/azure/mysql/flexible-server/overview#azure-regions).')
2121
@allowed([
2222
'australiaeast'
2323
'centralus'
@@ -30,13 +30,38 @@ param solutionUniqueText string = take(uniqueString(subscription().id, resourceG
3030
'westeurope'
3131
'uksouth'
3232
])
33-
param location string = 'australiaeast'
33+
param location string
3434

3535
// Restricting deployment to only supported Azure OpenAI regions validated with GPT-4o model
3636
@allowed(['australiaeast', 'eastus2', 'francecentral', 'japaneast', 'norwayeast', 'swedencentral', 'uksouth', 'westus'])
37-
@metadata({ azd: { type: 'location' } })
38-
@description('Optional. Location for all AI service resources. This should be one of the supported Azure AI Service locations.')
39-
param azureAiServiceLocation string = 'australiaeast'
37+
@metadata({
38+
azd : {
39+
type: 'location'
40+
usageName : [
41+
'OpenAI.GlobalStandard.gpt-4o, 150'
42+
]
43+
}
44+
})
45+
@description('Required. Location for all AI service resources. This should be one of the supported Azure AI Service locations.')
46+
param azureAiServiceLocation string
47+
48+
@minLength(1)
49+
@description('Optional. Name of the GPT model to deploy:')
50+
param gptModelName string = 'gpt-4o'
51+
52+
@description('Optional. Version of the GPT model to deploy. Defaults to 2024-08-06.')
53+
param gptModelVersion string = '2024-08-06'
54+
55+
@minLength(1)
56+
@allowed([
57+
'Standard'
58+
'GlobalStandard'
59+
])
60+
@description('Optional. GPT model deployment type. Defaults to GlobalStandard.')
61+
param gptModelDeploymentType string = 'GlobalStandard'
62+
63+
@description('Optional. AI model deployment token capacity. Defaults to 150 for optimal performance.')
64+
param gptModelCapacity int = 150
4065

4166
@description('Optional. The tags to apply to all deployed Azure resources.')
4267
param tags resourceInput<'Microsoft.Resources/resourceGroups@2025-04-01'>.tags = {}
@@ -86,7 +111,15 @@ param enableTelemetry bool = true
86111
// Variables //
87112
// ============== //
88113

89-
var solutionSuffix = '${solutionName}${solutionUniqueText}'
114+
var solutionSuffix = toLower(trim(replace(
115+
replace(
116+
replace(replace(replace(replace('${solutionName}${solutionUniqueText}', '-', ''), '_', ''), '.', ''), '/', ''),
117+
' ',
118+
''
119+
),
120+
'*',
121+
''
122+
)))
90123

91124
// Region pairs list based on article in [Azure regions list](https://learn.microsoft.com/azure/reliability/regions-list)
92125
// var azureRegionPairs = {
@@ -895,12 +928,11 @@ var aiFoundryAiServicesAiProjectResourceName = 'proj-${solutionSuffix}'
895928
var aiFoundryAIservicesEnabled = true
896929
var aiFoundryAiServicesModelDeployment = {
897930
format: 'OpenAI'
898-
name: 'gpt-4o'
899-
version: '2024-08-06'
931+
name: gptModelName
932+
version: gptModelVersion
900933
sku: {
901-
name: 'GlobalStandard'
902-
//Currently the capacity is set to 140 for optimal performance.
903-
capacity: 140
934+
name: gptModelDeploymentType
935+
capacity: gptModelCapacity
904936
}
905937
raiPolicyName: 'Microsoft.Default'
906938
}
@@ -1141,7 +1173,7 @@ module containerAppEnvironment 'br/public:avm/res/app/managed-environment:0.11.2
11411173
destination: 'log-analytics'
11421174
logAnalyticsConfiguration: {
11431175
customerId: logAnalyticsWorkspace!.outputs.logAnalyticsWorkspaceId
1144-
sharedKey: logAnalyticsWorkspace!.outputs.primarySharedKey
1176+
sharedKey: logAnalyticsWorkspace.outputs.primarySharedKey
11451177
}
11461178
}
11471179
: null
@@ -1331,6 +1363,10 @@ module containerApp 'br/public:avm/res/app/container-app:0.18.1' = {
13311363
name: 'AZURE_AI_AGENT_MODEL_DEPLOYMENT_NAME'
13321364
value: aiFoundryAiServicesModelDeployment.name
13331365
}
1366+
{
1367+
name: 'AZURE_CLIENT_ID'
1368+
value: userAssignedIdentity.outputs.clientId // NOTE: This is the client ID of the managed identity, not the Entra application, and is needed for the App Service to access the Cosmos DB account.
1369+
}
13341370
]
13351371
}
13361372
]

infra/main.parameters.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,18 @@
1111
"azureAiServiceLocation": {
1212
"value": "${AZURE_ENV_OPENAI_LOCATION}"
1313
},
14+
"gptModelDeploymentType": {
15+
"value": "${AZURE_ENV_MODEL_DEPLOYMENT_TYPE}"
16+
},
17+
"gptModelName": {
18+
"value": "${AZURE_ENV_MODEL_NAME}"
19+
},
20+
"gptModelVersion": {
21+
"value": "${AZURE_ENV_MODEL_VERSION}"
22+
},
23+
"gptModelCapacity": {
24+
"value": "${AZURE_ENV_MODEL_CAPACITY}"
25+
},
1426
"backendContainerImageTag": {
1527
"value": "${AZURE_ENV_IMAGE_TAG}"
1628
},

0 commit comments

Comments
 (0)