Skip to content

Commit ec88704

Browse files
committed
more changes
1 parent 98c3e38 commit ec88704

File tree

7 files changed

+20
-69
lines changed

7 files changed

+20
-69
lines changed

azure.yaml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,9 @@
22
# TODO: do we need hooks?
33
# TODO: do we need all of the variables?
44

5-
name: bogus
5+
name: azd-get-started-with-ai-agents
66
metadata:
7-
8-
9-
services:
10-
api_and_frontend:
11-
project: ./src
12-
language: py
13-
host: containerapp
7+
148

159
hooks:
1610
postprovision:

infra/api.bicep

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@ param tags object = {}
44

55
param identityName string
66
param containerAppsEnvironmentName string
7-
param containerRegistryName string
87
param serviceName string = 'api'
9-
param exists bool
108
param projectConnectionString string
119
param agentDeploymentName string
1210
param searchConnectionName string
@@ -16,6 +14,7 @@ param embeddingDeploymentDimensions string
1614
param searchServiceEndpoint string
1715
param agentName string
1816
param agentID string
17+
param projectName string
1918

2019
resource apiIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
2120
name: identityName
@@ -78,15 +77,13 @@ module app 'core/host/container-app-upsert.bicep' = {
7877
location: location
7978
tags: union(tags, { 'azd-service-name': serviceName })
8079
identityName: apiIdentity.name
81-
exists: exists
8280
containerAppsEnvironmentName: containerAppsEnvironmentName
83-
containerRegistryName: containerRegistryName
8481
targetPort: 50505
8582
env: env
83+
projectName: projectName
8684
}
8785
}
8886

8987
output SERVICE_API_IDENTITY_PRINCIPAL_ID string = apiIdentity.properties.principalId
9088
output SERVICE_API_NAME string = app.outputs.name
9189
output SERVICE_API_URI string = app.outputs.uri
92-
output SERVICE_API_IMAGE_NAME string = app.outputs.imageName

infra/core/host/container-app-upsert.bicep

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,6 @@ param containerMinReplicas int = 1
2323
@description('The name of the container')
2424
param containerName string = 'main'
2525

26-
@description('The name of the container registry')
27-
param containerRegistryName string = ''
28-
29-
@description('Hostname suffix for container registry. Set when deploying to sovereign clouds')
30-
param containerRegistryHostSuffix string = 'azurecr.io'
31-
3226
@allowed([ 'http', 'grpc' ])
3327
@description('The protocol used by Dapr to connect to the app, e.g., HTTP or gRPC')
3428
param daprAppProtocol string = 'http'
@@ -39,9 +33,6 @@ param daprEnabled bool = false
3933
@description('The Dapr app ID')
4034
param daprAppId string = containerName
4135

42-
@description('Specifies if the resource already exists')
43-
param exists bool = false
44-
4536
@description('Specifies if Ingress is enabled for the container app')
4637
param ingressEnabled bool = true
4738

@@ -52,9 +43,6 @@ param identityType string = 'None'
5243
@description('The name of the user-assigned identity')
5344
param identityName string = ''
5445

55-
@description('The name of the container image')
56-
param imageName string = ''
57-
5846
@description('The secrets required for the container')
5947
@secure()
6048
param secrets object = {}
@@ -71,9 +59,8 @@ param serviceBinds array = []
7159
@description('The target port for the container')
7260
param targetPort int = 80
7361

74-
resource existingApp 'Microsoft.App/containerApps@2023-05-02-preview' existing = if (exists) {
75-
name: 'crgetstartwithaiagents'
76-
}
62+
param projectName string
63+
7764

7865
module app 'container-app.bicep' = {
7966
name: '${deployment().name}-update'
@@ -86,8 +73,6 @@ module app 'container-app.bicep' = {
8673
ingressEnabled: ingressEnabled
8774
containerName: containerName
8875
containerAppsEnvironmentName: containerAppsEnvironmentName
89-
// containerRegistryName: containerRegistryName
90-
containerRegistryHostSuffix: containerRegistryHostSuffix
9176
containerCpuCoreCount: containerCpuCoreCount
9277
containerMemory: containerMemory
9378
containerMinReplicas: containerMinReplicas
@@ -98,13 +83,12 @@ module app 'container-app.bicep' = {
9883
secrets: secrets
9984
external: external
10085
env: env
101-
imageName: !empty(imageName) ? imageName : exists ? existingApp.properties.template.containers[0].image : ''
10286
targetPort: targetPort
10387
serviceBinds: serviceBinds
88+
dependOn: projectName
10489
}
10590
}
10691

10792
output defaultDomain string = app.outputs.defaultDomain
108-
output imageName string = app.outputs.imageName
10993
output name string = app.outputs.name
11094
output uri string = app.outputs.uri

infra/core/host/container-app.bicep

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,6 @@ param containerMinReplicas int = 1
2525
@description('The name of the container')
2626
param containerName string = 'main'
2727

28-
// @description('The name of the container registry')
29-
// param containerRegistryName string = ''
30-
31-
@description('Hostname suffix for container registry. Set when deploying to sovereign clouds')
32-
param containerRegistryHostSuffix string = 'azurecr.io'
33-
3428
@description('The protocol used by Dapr to connect to the app, e.g., http or grpc')
3529
@allowed([ 'http', 'grpc' ])
3630
param daprAppProtocol string = 'http'
@@ -54,14 +48,14 @@ param identityName string = ''
5448
@allowed([ 'None', 'SystemAssigned', 'UserAssigned' ])
5549
param identityType string = 'None'
5650

57-
@description('The name of the container image')
58-
param imageName string = ''
5951

6052
@description('Specifies if Ingress is enabled for the container app')
6153
param ingressEnabled bool = true
6254

6355
param revisionMode string = 'Single'
6456

57+
param dependOn string = ''
58+
6559
@description('The secrets required for the container')
6660
@secure()
6761
param secrets object = {}
@@ -79,20 +73,9 @@ resource userIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-
7973
name: identityName
8074
}
8175

82-
// Private registry support requires both an ACR name and a User Assigned managed identity
83-
// var usePrivateRegistry = !empty(identityName) && !empty(containerRegistryName)
84-
8576
// Automatically set to `UserAssigned` when an `identityName` has been set
8677
var normalizedIdentityType = !empty(identityName) ? 'UserAssigned' : identityType
8778

88-
// module containerRegistryAccess '../security/registry-access.bicep' = if (usePrivateRegistry) {
89-
// name: '${deployment().name}-registry-access'
90-
// params: {
91-
// containerRegistryName: containerRegistryName
92-
// principalId: usePrivateRegistry ? userIdentity.properties.principalId : ''
93-
// }
94-
// }
95-
9679
resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
9780
name: name
9881
location: location
@@ -101,7 +84,7 @@ resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
10184
// otherwise the container app will throw a provision error
10285
// This also forces us to use an user assigned managed identity since there would no way to
10386
// provide the system assigned identity with the ACR pull access before the app is created
104-
dependsOn: []
87+
dependsOn: empty(dependOn)? [] : [dependOn]
10588
identity: {
10689
type: normalizedIdentityType
10790
userAssignedIdentities: !empty(identityName) && normalizedIdentityType == 'UserAssigned' ? { '${userIdentity.id}': {} } : null
@@ -158,7 +141,6 @@ resource containerAppsEnvironment 'Microsoft.App/managedEnvironments@2023-05-01'
158141

159142
output defaultDomain string = containerAppsEnvironment.properties.defaultDomain
160143
output identityPrincipalId string = normalizedIdentityType == 'None' ? '' : (empty(identityName) ? app.identity.principalId : userIdentity.properties.principalId)
161-
output imageName string = imageName
162144
output name string = app.name
163145
output serviceBind object = !empty(serviceType) ? { serviceId: app.id, name: name } : {}
164146
output uri string = ingressEnabled ? 'https://${app.properties.configuration.ingress.fqdn}' : ''

infra/main.bicep

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ param applicationInsightsName string = ''
3939
param aiServicesName string = ''
4040
@description('The AI Services connection name. If ommited will use a default value')
4141
param aiServicesConnectionName string = ''
42-
@description('The Azure Container Registry resource name. If ommited will be generated')
43-
param containerRegistryName string = ''
4442
@description('The Azure Key Vault resource name. If ommited will be generated')
4543
param keyVaultName string = ''
4644
@description('The Azure Search resource name. If ommited will be generated')
@@ -154,8 +152,6 @@ var aiDeployments = concat(
154152
aiChatModel,
155153
useSearchService ? aiEmbeddingModel : [])
156154

157-
//for container and app api
158-
param apiAppExists bool = false
159155

160156
// Organize resources in a resource group
161157
resource rg 'Microsoft.Resources/resourceGroups@2021-04-01' = {
@@ -174,10 +170,6 @@ var resolvedSearchServiceName = !useSearchService
174170
? ''
175171
: !empty(searchServiceName) ? searchServiceName : '${abbrs.searchSearchServices}${resourceToken}'
176172

177-
var containerRegistryResolvedName = !useContainerRegistry
178-
? ''
179-
: !empty(containerRegistryName) ? containerRegistryName : '${abbrs.containerRegistryRegistries}${resourceToken}'
180-
181173
module ai 'core/host/ai-environment.bicep' = if (empty(aiExistingProjectConnectionString)) {
182174
name: 'ai'
183175
scope: rg
@@ -197,7 +189,6 @@ module ai 'core/host/ai-environment.bicep' = if (empty(aiExistingProjectConnecti
197189
applicationInsightsName: !useApplicationInsights
198190
? ''
199191
: !empty(applicationInsightsName) ? applicationInsightsName : '${abbrs.insightsComponents}${resourceToken}'
200-
containerRegistryName: containerRegistryResolvedName
201192
searchServiceName: resolvedSearchServiceName
202193
searchConnectionName: !useSearchService
203194
? ''
@@ -260,10 +251,8 @@ module containerApps 'core/host/container-apps.bicep' = {
260251
name: 'app'
261252
location: location
262253
tags: tags
254+
containerRegistryName: '${abbrs.containerRegistryRegistries}${resourceToken}'
263255
containerAppsEnvironmentName: 'containerapps-env-${resourceToken}'
264-
containerRegistryName: empty(aiExistingProjectConnectionString)
265-
? ai.outputs.containerRegistryName
266-
: containerRegistryResolvedName
267256
logAnalyticsWorkspaceName: empty(aiExistingProjectConnectionString)
268257
? ai.outputs.logAnalyticsWorkspaceName
269258
: logAnalytics.outputs.name
@@ -283,7 +272,6 @@ module api 'api.bicep' = {
283272
identityName: '${abbrs.managedIdentityUserAssignedIdentities}api-${resourceToken}'
284273
containerAppsEnvironmentName: containerApps.outputs.environmentName
285274
//containerRegistryName: containerApps.outputs.registryName
286-
containerRegistryName: 'crgetstartwithaiagents'
287275
projectConnectionString: projectConnectionString
288276
agentDeploymentName: agentDeploymentName
289277
searchConnectionName: searchConnectionName
@@ -293,7 +281,7 @@ module api 'api.bicep' = {
293281
embeddingDeploymentDimensions: embeddingDeploymentDimensions
294282
agentName: agentName
295283
agentID: agentID
296-
exists: apiAppExists
284+
projectName: projectName
297285
}
298286
}
299287

@@ -426,5 +414,4 @@ output AZURE_CONTAINER_REGISTRY_ENDPOINT string = containerApps.outputs.registry
426414
output SERVICE_API_IDENTITY_PRINCIPAL_ID string = api.outputs.SERVICE_API_IDENTITY_PRINCIPAL_ID
427415
output SERVICE_API_NAME string = api.outputs.SERVICE_API_NAME
428416
output SERVICE_API_URI string = api.outputs.SERVICE_API_URI
429-
output SERVICE_API_IMAGE_NAME string = api.outputs.SERVICE_API_IMAGE_NAME
430417
output SERVICE_API_ENDPOINTS array = ['${api.outputs.SERVICE_API_URI}']

scripts/write_env.ps1

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ $azureAIEmbedDeploymentName = azd env get-value AZURE_AI_EMBED_DEPLOYMENT_NAME
1515
$azureAIEmbedDimensions = azd env get-value AZURE_AI_EMBED_DIMENSIONS
1616
$azureAISearchIndexName = azd env get-value AZURE_AI_SEARCH_INDEX_NAME
1717
$azureAISearchEndpoint = azd env get-value AZURE_AI_SEARCH_ENDPOINT
18+
$serviceAPIUri = azd env get-value SERVICE_API_URI
1819

1920
Add-Content -Path $envFilePath -Value "AZURE_AIPROJECT_CONNECTION_STRING=$azureAiProjectConnectionString"
2021
Add-Content -Path $envFilePath -Value "AZURE_AI_AGENT_DEPLOYMENT_NAME=$azureAiagentDeploymentName"
@@ -26,4 +27,7 @@ Add-Content -Path $envFilePath -Value "AZURE_AI_EMBED_DIMENSIONS=$azureAIEmbedDi
2627
Add-Content -Path $envFilePath -Value "AZURE_AI_SEARCH_INDEX_NAME=$azureAISearchIndexName"
2728
Add-Content -Path $envFilePath -Value "AZURE_AI_SEARCH_ENDPOINT=$azureAISearchEndpoint"
2829
Add-Content -Path $envFilePath -Value "AZURE_AI_AGENT_NAME=$azureAiAgentName"
29-
Add-Content -Path $envFilePath -Value "AZURE_TENANT_ID=$azureTenantId"
30+
Add-Content -Path $envFilePath -Value "AZURE_TENANT_ID=$azureTenantId"
31+
32+
Write-Host "Web app URL:"
33+
Write-Host $serviceAPIUri -ForegroundColor Cyan

scripts/write_env.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@ echo "AZURE_AI_SEARCH_INDEX_NAME=$(azd env get-value AZURE_AI_SEARCH_INDEX_NAME)
1717
echo "AZURE_AI_SEARCH_ENDPOINT=$(azd env get-value AZURE_AI_SEARCH_ENDPOINT)" >> $ENV_FILE_PATH
1818
echo "AZURE_AI_AGENT_NAME=$(azd env get-value AZURE_AI_AGENT_NAME)" >> $ENV_FILE_PATH
1919
echo "AZURE_TENANT_ID=$(azd env get-value AZURE_TENANT_ID)" >> $ENV_FILE_PATH
20+
21+
echo "Web app URL:"
22+
echo "$(azd env get-value SERVICE_API_URI)"
2023
exit 0

0 commit comments

Comments
 (0)