Skip to content

Commit 1c6ee66

Browse files
committed
asssign public image to container app
1 parent 56c3ffe commit 1c6ee66

File tree

6 files changed

+102
-26
lines changed

6 files changed

+102
-26
lines changed

.azdo/pipelines/azure-dev.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Run when commits are pushed to mainline branch (main or master)
2+
# Set this to the mainline branch you are using
3+
trigger:
4+
- main
5+
- master
6+
7+
# Azure Pipelines workflow to deploy to Azure using azd
8+
# To configure required secrets and service connection for connecting to Azure, simply run `azd pipeline config --provider azdo`
9+
# Task "Install azd" needs to install setup-azd extension for azdo - https://marketplace.visualstudio.com/items?itemName=ms-azuretools.azd
10+
# See below for alternative task to install azd if you can't install above task in your organization
11+
12+
pool:
13+
vmImage: ubuntu-latest
14+
15+
steps:
16+
- task: setup-azd@0
17+
displayName: Install azd
18+
19+
# If you can't install above task in your organization, you can comment it and uncomment below task to install azd
20+
# - task: Bash@3
21+
# displayName: Install azd
22+
# inputs:
23+
# targetType: 'inline'
24+
# script: |
25+
# curl -fsSL https://aka.ms/install-azd.sh | bash
26+
27+
# azd delegate auth to az to use service connection with AzureCLI@2
28+
- pwsh: |
29+
azd config set auth.useAzCliAuth "true"
30+
displayName: Configure AZD to Use AZ CLI Authentication.
31+
32+
- task: AzureCLI@2
33+
displayName: Provision Infrastructure
34+
inputs:
35+
azureSubscription: azconnection
36+
scriptType: bash
37+
scriptLocation: inlineScript
38+
inlineScript: |
39+
azd provision --no-prompt
40+
env:
41+
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
42+
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
43+
AZURE_LOCATION: $(AZURE_LOCATION)
44+
# Project specific environment variables
45+
AZURE_RESOURCE_GROUP: $(AZURE_RESOURCE_GROUP)
46+
AZURE_AIHUB_NAME: $(AZURE_AIHUB_NAME)
47+
AZURE_AIPROJECT_NAME: $(AZURE_AIPROJECT_NAME)
48+
AZURE_AISERVICES_NAME: $(AZURE_AISERVICES_NAME)
49+
AZURE_SEARCH_SERVICE_NAME: $(AZURE_SEARCH_SERVICE_NAME)
50+
AZURE_APPLICATION_INSIGHTS_NAME: $(AZURE_APPLICATION_INSIGHTS_NAME)
51+
AZURE_CONTAINER_REGISTRY_NAME: $(AZURE_CONTAINER_REGISTRY_NAME)
52+
AZURE_KEYVAULT_NAME: $(AZURE_KEYVAULT_NAME)
53+
AZURE_STORAGE_ACCOUNT_NAME: $(AZURE_STORAGE_ACCOUNT_NAME)
54+
AZURE_LOG_ANALYTICS_WORKSPACE_NAME: $(AZURE_LOG_ANALYTICS_WORKSPACE_NAME)
55+
USE_CONTAINER_REGISTRY: $(USE_CONTAINER_REGISTRY)
56+
USE_APPLICATION_INSIGHTS: $(USE_APPLICATION_INSIGHTS)
57+
USE_SEARCH_SERVICE: $(USE_SEARCH_SERVICE)
58+
AZURE_AI_AGENT_DEPLOYMENT_NAME: $(AZURE_AI_AGENT_DEPLOYMENT_NAME)
59+
AZURE_AI_AGENT_DEPLOYMENT_SKU: $(AZURE_AI_AGENT_DEPLOYMENT_SKU)
60+
AZURE_AI_AGENT_DEPLOYMENT_CAPACITY: $(AZURE_AI_AGENT_DEPLOYMENT_CAPACITY)
61+
AZURE_AI_AGENT_MODEL_FORMAT: $(AZURE_AI_AGENT_MODEL_FORMAT)
62+
AZURE_AI_AGENT_MODEL_NAME: $(AZURE_AI_AGENT_MODEL)
63+
AZURE_AI_AGENT_MODEL_VERSION: $(AZURE_AI_AGENT_MODEL_VERSION)
64+
AZURE_AI_EMBED_DEPLOYMENT_NAME: $(AZURE_AI_EMBED_DEPLOYMENT_NAME)
65+
AZURE_AI_EMBED_DEPLOYMENT_SKU: $(AZURE_AI_EMBED_DEPLOYMENT_SKU)
66+
AZURE_AI_EMBED_DEPLOYMENT_CAPACITY: $(AZURE_AI_EMBED_DEPLOYMENT_CAPACITY)
67+
AZURE_AI_EMBED_MODEL_FORMAT: $(AZURE_AI_EMBED_MODEL_FORMAT)
68+
AZURE_AI_EMBED_MODEL_NAME: $(AZURE_AI_EMBED_MODEL_NAME)
69+
AZURE_AI_EMBED_MODEL_VERSION: $(AZURE_AI_EMBED_MODEL_VERSION)
70+
AZURE_EXISTING_AIPROJECT_CONNECTION_STRING: $(AZURE_EXISTING_AIPROJECT_CONNECTION_STRING)
71+
- task: AzureCLI@2
72+
displayName: Deploy Application
73+
inputs:
74+
azureSubscription: azconnection
75+
scriptType: bash
76+
scriptLocation: inlineScript
77+
inlineScript: |
78+
azd deploy --no-prompt
79+
env:
80+
AZURE_SUBSCRIPTION_ID: $(AZURE_SUBSCRIPTION_ID)
81+
AZURE_ENV_NAME: $(AZURE_ENV_NAME)
82+
AZURE_LOCATION: $(AZURE_LOCATION)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The app code runs in Azure Container apps to process the user input and generate
2525

2626
### Quick Deploy
2727

28-
| [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/get-started-with-ai-agents) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/get-started-with-ai-agents) | [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fget-started-with-ai-agents%2Frefs%2Fheads%2Fmain%2Finfra%2Fmain.json) |
28+
| [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/Azure-Samples/get-started-with-ai-agents) | [![Open in Dev Containers](https://img.shields.io/static/v1?style=for-the-badge&label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode)](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/get-started-with-ai-agents) | [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure-Samples%2Fget-started-with-ai-agents%2Frefs%2Fheads%2Fhowie%2Ffix-deploy-to-azure%2Finfra%2Fmain.json) |
2929
|---|---|---|
3030

3131
Github Codespaces and Dev Containers both allow you to download and deploy the code for development. You can also continue with local development. Once you have selected your environment, follow the instructions below to customize and deploy your solution.

azure.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ services:
1111
project: ./src
1212
language: py
1313
host: containerapp
14-
docker:
15-
image: api-and-frontend
16-
remoteBuild: true
1714

1815
hooks:
1916
postprovision:

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ param serviceBinds array = []
7272
param targetPort int = 80
7373

7474
resource existingApp 'Microsoft.App/containerApps@2023-05-02-preview' existing = if (exists) {
75-
name: name
75+
name: 'crgetstartwithaiagents'
7676
}
7777

7878
module app 'container-app.bicep' = {
@@ -86,7 +86,7 @@ module app 'container-app.bicep' = {
8686
ingressEnabled: ingressEnabled
8787
containerName: containerName
8888
containerAppsEnvironmentName: containerAppsEnvironmentName
89-
containerRegistryName: containerRegistryName
89+
// containerRegistryName: containerRegistryName
9090
containerRegistryHostSuffix: containerRegistryHostSuffix
9191
containerCpuCoreCount: containerCpuCoreCount
9292
containerMemory: containerMemory

infra/core/host/container-app.bicep

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ 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 = ''
28+
// @description('The name of the container registry')
29+
// param containerRegistryName string = ''
3030

3131
@description('Hostname suffix for container registry. Set when deploying to sovereign clouds')
3232
param containerRegistryHostSuffix string = 'azurecr.io'
@@ -80,18 +80,18 @@ resource userIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-
8080
}
8181

8282
// Private registry support requires both an ACR name and a User Assigned managed identity
83-
var usePrivateRegistry = !empty(identityName) && !empty(containerRegistryName)
83+
// var usePrivateRegistry = !empty(identityName) && !empty(containerRegistryName)
8484

8585
// Automatically set to `UserAssigned` when an `identityName` has been set
8686
var normalizedIdentityType = !empty(identityName) ? 'UserAssigned' : identityType
8787

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-
}
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+
// }
9595

9696
resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
9797
name: name
@@ -101,7 +101,7 @@ resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
101101
// otherwise the container app will throw a provision error
102102
// This also forces us to use an user assigned managed identity since there would no way to
103103
// provide the system assigned identity with the ACR pull access before the app is created
104-
dependsOn: usePrivateRegistry ? [ containerRegistryAccess ] : []
104+
dependsOn: []
105105
identity: {
106106
type: normalizedIdentityType
107107
userAssignedIdentities: !empty(identityName) && normalizedIdentityType == 'UserAssigned' ? { '${userIdentity.id}': {} } : null
@@ -129,18 +129,13 @@ resource app 'Microsoft.App/containerApps@2023-05-02-preview' = {
129129
value: secret.value
130130
}]
131131
service: !empty(serviceType) ? { type: serviceType } : null
132-
registries: usePrivateRegistry ? [
133-
{
134-
server: '${containerRegistryName}.${containerRegistryHostSuffix}'
135-
identity: userIdentity.id
136-
}
137-
] : []
132+
registries: []
138133
}
139134
template: {
140135
serviceBinds: !empty(serviceBinds) ? serviceBinds : null
141136
containers: [
142137
{
143-
image: !empty(imageName) ? imageName : 'mcr.microsoft.com/azuredocs/containerapps-hh:latest'
138+
image: 'crgetstartwithaiagents.azurecr.io/get-start-with-ai-agents:get-start-with-ai-agents-latest'
144139
name: containerName
145140
env: env
146141
resources: {

infra/main.bicep

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,10 +278,12 @@ module api 'api.bicep' = {
278278
name: 'ca-api-${resourceToken}'
279279
location: location
280280
tags: tags
281-
serviceName: 'api_and_frontend'
281+
serviceName: 'api_and_frontend'
282+
// serviceName: 'get-started-with-ai-agents'
282283
identityName: '${abbrs.managedIdentityUserAssignedIdentities}api-${resourceToken}'
283284
containerAppsEnvironmentName: containerApps.outputs.environmentName
284-
containerRegistryName: containerApps.outputs.registryName
285+
//containerRegistryName: containerApps.outputs.registryName
286+
containerRegistryName: 'crgetstartwithaiagents'
285287
projectConnectionString: projectConnectionString
286288
agentDeploymentName: agentDeploymentName
287289
searchConnectionName: searchConnectionName

0 commit comments

Comments
 (0)