Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AZD-ify the deploy to AI lab #51

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
},
"ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools:1": {
"version": "latest"
}
},
"ghcr.io/azure/azure-dev/azd:0": {}
}

}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
*.userosscache
*.sln.docstates

.azure

# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs

Expand Down
15 changes: 15 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json
name: intro-intelligent-apps
services:
frontend:
project: ./labs/04-deploy-ai/02-frontend-ui/chainlitagent-ui
language: python
host: containerapp
api-python:
project: ./labs/04-deploy-ai/01-backend-api/acs-lc-python-api/acs-lc-python
language: python
host: containerapp
api-csharp:
project: ./labs/04-deploy-ai/01-backend-api/acs-sk-csharp-api/acs-sk-csharp
language: csharp
host: containerapp
16 changes: 16 additions & 0 deletions infra/abbreviations.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"appManagedEnvironments": "cae-",
"containerRegistryRegistries": "cr",
"insightsComponents": "appi-",
"operationalInsightsWorkspaces": "log-",
"portalDashboards": "dash-",
"resourcesResourceGroups": "rg-",
"storageStorageAccounts": "st",
"webServerFarms": "plan-",
"webSitesFunctions": "func-",
"kustoCluster": "kc-",
"managedIdentityUserAssignedIdentities": "id-",
"appContainerApps":"ca-",
"postgresServiceName": "pg-",
"searchService":"acs-"
}
114 changes: 114 additions & 0 deletions infra/app/api-csharp.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
param name string
param location string = resourceGroup().location
param tags object = {}

param applicationInsightsName string = ''
param identityName string
param serviceName string = 'api-csharp'

param containerAppsEnvironmentName string
param containerRegistryName string
param openAICompletionDeploymentName string
param openAIEmbeddingDeploymentName string
param openAICompletionModel string
@secure()
param openAIKey string
param openAIEndpoint string
param searchServiceName string
param searchIndexName string
param searchServiceEndpoint string


resource apiGraphIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: identityName
location: location
}

resource search 'Microsoft.Search/searchServices@2021-04-01-preview' existing = {
name: searchServiceName
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
name: applicationInsightsName
}

module app '../core/host/container-app.bicep' = {
name: '${serviceName}-api-csharp'
params: {
name: name
location: location
tags: union(tags, { 'azd-service-name': serviceName })
identityType: 'UserAssigned'
identityName: apiGraphIdentity.name
containerAppsEnvironmentName: containerAppsEnvironmentName
containerRegistryName: containerRegistryName
containerCpuCoreCount: '1.0'
containerMemory: '2.0Gi'
env: [
{
name: 'AZURE_CLIENT_ID'
value: apiGraphIdentity.properties.clientId
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: applicationInsights.properties.ConnectionString
}
{
name: 'AZURE_OPENAI_COMPLETION_DEPLOYMENT_NAME'
value: openAICompletionDeploymentName
}
{
name: 'AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME'
value: openAIEmbeddingDeploymentName
}
{
name: 'AZURE_COGNITIVE_SEARCH_SERVICE_NAME'
value: searchServiceName
}
{
name: 'AZURE_COGNITIVE_SEARCH_ENDPOINT_NAME'
value: searchServiceEndpoint
}
{
name: 'AZURE_COGNITIVE_SEARCH_INDEX_NAME'
value: searchIndexName
}
{
name: 'AZURE_COGNITIVE_SEARCH_API_KEY'
value: search.listAdminKeys().primaryKey
}
{
name: 'AZURE_TENANT_ID'
value: apiGraphIdentity.properties.tenantId
}
{
name: 'OPENAI_COMPLETION_MODEL'
value: openAICompletionModel
}
{
name: 'OPENAI_API_VERSION'
value: '2023-05-15'
}
{
name: 'OPENAI_API_BASE'
value: openAIEndpoint
}
{
name: 'OPENAI_API_KEY'
value: openAIKey
}
{
name: 'OPENAI_API_TYPE'
value: 'azure'
}
]
targetPort: 5291
}
}



output SERVICE_API_CSHARP_IDENTITY_PRINCIPAL_ID string = apiGraphIdentity.properties.principalId
output SERVICE_API_CSHARP_NAME string = app.outputs.name
output SERVICE_API_CSHARP_URI string = app.outputs.uri
output SERVICE_API_CSHARP_IMAGE_NAME string = app.outputs.imageName
113 changes: 113 additions & 0 deletions infra/app/api-python.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
param name string
param location string = resourceGroup().location
param tags object = {}

param applicationInsightsName string = ''
param identityName string
param serviceName string = 'api-python'

param containerAppsEnvironmentName string
param containerRegistryName string

param openAICompletionDeploymentName string
param openAIEmbeddingDeploymentName string
param openAICompletionModel string
@secure()
param openAIKey string
param openAIEndpoint string
param searchServiceName string
param searchIndexName string
param searchServiceEndpoint string

resource apiGraphIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: identityName
location: location
}

resource search 'Microsoft.Search/searchServices@2021-04-01-preview' existing = {
name: searchServiceName
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
name: applicationInsightsName
}

module app '../core/host/container-app.bicep' = {
name: '${serviceName}-api-python'
params: {
name: name
location: location
tags: union(tags, { 'azd-service-name': serviceName })
identityType: 'UserAssigned'
identityName: apiGraphIdentity.name
containerAppsEnvironmentName: containerAppsEnvironmentName
containerRegistryName: containerRegistryName
containerCpuCoreCount: '1.0'
containerMemory: '2.0Gi'
env: [
{
name: 'AZURE_CLIENT_ID'
value: apiGraphIdentity.properties.clientId
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: applicationInsights.properties.ConnectionString
}
{
name: 'AZURE_OPENAI_COMPLETION_DEPLOYMENT_NAME'
value: openAICompletionDeploymentName
}
{
name: 'AZURE_OPENAI_EMBEDDING_DEPLOYMENT_NAME'
value: openAIEmbeddingDeploymentName
}
{
name: 'AZURE_COGNITIVE_SEARCH_SERVICE_NAME'
value: searchServiceName
}
{
name: 'AZURE_COGNITIVE_SEARCH_ENDPOINT_NAME'
value: searchServiceEndpoint
}
{
name: 'AZURE_COGNITIVE_SEARCH_INDEX_NAME'
value: searchIndexName
}
{
name: 'AZURE_COGNITIVE_SEARCH_API_KEY'
value: search.listAdminKeys().primaryKey
}
{
name: 'AZURE_TENANT_ID'
value: apiGraphIdentity.properties.tenantId
}
{
name: 'OPENAI_COMPLETION_MODEL'
value: openAICompletionModel
}
{
name: 'OPENAI_API_VERSION'
value: '2023-05-15'
}
{
name: 'OPENAI_API_BASE'
value: openAIEndpoint
}
{
name: 'OPENAI_API_KEY'
value: openAIKey
}
{
name: 'OPENAI_API_TYPE'
value: 'azure'
}
]
targetPort: 5291
}
}


output SERVICE_API_PYTHON_IDENTITY_PRINCIPAL_ID string = apiGraphIdentity.properties.principalId
output SERVICE_API_PYTHON_NAME string = app.outputs.name
output SERVICE_API_PYTHON_URI string = app.outputs.uri
output SERVICE_API_PYTHON_IMAGE_NAME string = app.outputs.imageName
56 changes: 56 additions & 0 deletions infra/app/frontend.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
param name string
param location string = resourceGroup().location
param tags object = {}

param applicationInsightsName string = ''
param identityName string
param serviceName string = 'frontend'

param containerAppsEnvironmentName string
param containerRegistryName string

param backendApiUrl string

resource frontendIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2023-01-31' = {
name: identityName
location: location
}

resource applicationInsights 'Microsoft.Insights/components@2020-02-02' existing = {
name: applicationInsightsName
}

module app '../core/host/container-app.bicep' = {
name: '${serviceName}-frontend'
params: {
name: name
location: location
tags: union(tags, { 'azd-service-name': serviceName })
identityType: 'UserAssigned'
identityName: frontendIdentity.name
containerAppsEnvironmentName: containerAppsEnvironmentName
containerRegistryName: containerRegistryName
containerCpuCoreCount: '1.0'
containerMemory: '2.0Gi'
env: [
{
name: 'AZURE_CLIENT_ID'
value: frontendIdentity.properties.clientId
}
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
value: applicationInsights.properties.ConnectionString
}
{
name: 'BACKEND_API_BASE'
value: backendApiUrl
}
]
targetPort: 8000
}
}

output SERVICE_FRONTEND_API_IDENTITY_PRINCIPAL_ID string = frontendIdentity.properties.principalId
output SERVICE_FRONTEND_API_NAME string = app.outputs.name
output SERVICE_FRONTEND_API_URI string = app.outputs.uri
output SERVICE_FRONTEND_API_IMAGE_NAME string = app.outputs.imageName
Loading