Skip to content
Merged
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
7 changes: 7 additions & 0 deletions azure.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,11 @@ hooks:
windows:
shell: pwsh
run: $timestamp = Get-Date -Format "yyyyMMdd-HHmmss"; $logFile = "azd_preprovision_$timestamp.log"; ./infra/scripts/docker-build.ps1 $env:AZURE_SUBSCRIPTION_ID $env:AZURE_ENV_NAME $env:AZURE_LOCATION $env:AZURE_RESOURCE_GROUP $env:USE_LOCAL_BUILD *>&1 | Tee-Object -FilePath $logFile
postprovision:
posix:
shell: sh
run: sed -i 's/\r$//' ./infra/scripts/post_deployment.sh; ./infra/scripts/post_deployment.sh
windows:
shell: pwsh
run: ./infra/scripts/post_deployment.ps1

8 changes: 4 additions & 4 deletions docs/ConfigureAppAuthentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ We will add Microsoft Entra ID as an authentication provider to API and Web Appl
3. Grab Scope Name for Impersonation

- Select **Expose an API** in the left menu. Copy the Scope name, then paste it in some temporary place.
The copied text will be used for Web Application Environment variable - **APP_MSAL_AUTH_SCOPE**.
The copied text will be used for Web Application Environment variable - **APP_WEB_SCOPE**.
![configure_app_registration_web_9](./Images/configure_app_registration_web_9.png)

4. Grab Client Id for Web App

- Select **Overview** in the left menu. Copy the Client Id, then paste it in some temporary place.
The copied text will be used for Web Application Environment variable - **APP_MSAL_AUTH_CLIENT_ID**.
The copied text will be used for Web Application Environment variable - **APP_WEB_CLIENT_ID**.
![configure_app_registration_web_10](./Images/configure_app_registration_web_10.png)

## Step 3: Configure Application Registration - API Application
Expand All @@ -90,7 +90,7 @@ We will add Microsoft Entra ID as an authentication provider to API and Web Appl
![configure_app_registration_api_1](./Images/configure_app_registration_api_1.png)

- Select **Expose an API** in the left menu. Copy the Scope name, then paste it in some temporary place.
The copied text will be used for Web Application Environment variable - **APP_MSAL_TOKEN_SCOPE**.
The copied text will be used for Web Application Environment variable - **APP_API_SCOPE**.
![configure_app_registration_api_2](./Images/configure_app_registration_api_2.png)

## Step 4: Add Web Application's Client Id to Allowed Client Applications List in API Application Registration
Expand All @@ -112,7 +112,7 @@ Now, we will edit and deploy the Web Application Container with updated Environm

1. Select **Containers** menu under **Application**. Then click **Environment variables** tab.
![update_env_app_1_1](./Images/update_env_app_1_1.png)
2. Update 3 values which were taken in previous steps for **APP_MSAL_AUTH_CLIENT_ID**, **APP_MSAL_AUTH_SCOPE**, **APP_MSAL_TOKEN_SCOPE**.
2. Update 3 values which were taken in previous steps for **APP_WEB_CLIENT_ID**, **APP_WEB_SCOPE**, **APP_API_SCOPE**.
Click on **Save as a new revision**.
The updated revision will be activated soon.

Expand Down
Binary file modified docs/Images/update_env_app_1_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions infra/container_app/deploy_container_app_api_web.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -131,23 +131,23 @@ module containerAppWeb 'deploy_container_app.bicep' = {
value: containerAppApiEndpoint
}
{
name: 'APP_MSAL_AUTH_CLIENT_ID'
name: 'APP_WEB_CLIENT_ID'
value: '<APP_REGISTRATION_CLIENTID>'
}
{
name: 'APP_MSAL_AUTH_AUTHORITY'
name: 'APP_WEB_AUTHORITY'
value: '${environment().authentication.loginEndpoint}/${tenant().tenantId}'
}
{
name: 'APP_MSAL_AUTH_SCOPE'
name: 'APP_WEB_SCOPE'
value: '<FRONTEND_API_SCOPE>'
}
{
name: 'APP_MSAL_TOKEN_SCOPE'
name: 'APP_API_SCOPE'
value: '<BACKEND_API_SCOPE>'
}
{
name: 'APP_ISLOGS_ENABLED'
name: 'APP_CONSOLE_LOG_ENABLED'
value: 'false'
}
]
Expand Down
34 changes: 8 additions & 26 deletions infra/deploy_container_registry.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -3,49 +3,31 @@
targetScope = 'resourceGroup'

param environmentName string

var uniqueId = toLower(uniqueString(subscription().id, environmentName, resourceGroup().location))
var solutionName = 'cps-${padLeft(take(uniqueId, 12), 12, '0')}'

var containerNameCleaned = replace('cr${solutionName }', '-', '')

@description('Provide a location for the registry.')
param location string = resourceGroup().location

@description('Provide a tier of your Azure Container Registry.')
param acrSku string = 'Premium'

param acrSku string = 'Basic'
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2021-09-01' = {
name: containerNameCleaned
location: location
sku: {
name: acrSku
}
properties: {
adminUserEnabled: true
dataEndpointEnabled: false
networkRuleBypassOptions: 'AzureServices'
networkRuleSet: {
defaultAction: 'Allow'
}
policies: {
quarantinePolicy: {
status: 'disabled'
}
retentionPolicy: {
status: 'enabled'
days: 7
}
trustPolicy: {
status: 'disabled'
type: 'Notary'
}
}
publicNetworkAccess: 'Enabled'
zoneRedundancy: 'Disabled'
}
}

output createdAcrName string = containerNameCleaned
output createdAcrId string = containerRegistry.id
output acrEndpoint string = containerRegistry.properties.loginServer

1 change: 0 additions & 1 deletion infra/deploy_keyvault.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ resource keyVault 'Microsoft.KeyVault/vaults@2022-07-01' = {
enabledForDiskEncryption: true
enabledForTemplateDeployment: true
enableRbacAuthorization: true
enablePurgeProtection: true
publicNetworkAccess: 'enabled'
// networkAcls: {
// bypass: 'AzureServices'
Expand Down
3 changes: 3 additions & 0 deletions infra/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ param gptModelName string = 'gpt-4o'

@minLength(1)
@description('Version of the GPT model to deploy:')
@allowed([
'2024-08-06'
])
param gptModelVersion string = '2024-08-06'

//var gptModelVersion = '2024-02-15-preview'
Expand Down
55 changes: 19 additions & 36 deletions infra/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "17985360808056860425"
"templateHash": "2631796362162534903"
}
},
"parameters": {
Expand Down Expand Up @@ -67,6 +67,9 @@
"gptModelVersion": {
"type": "string",
"defaultValue": "2024-08-06",
"allowedValues": [
"2024-08-06"
],
"minLength": 1,
"metadata": {
"description": "Version of the GPT model to deploy:"
Expand Down Expand Up @@ -480,7 +483,7 @@
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "7568462549649877267"
"templateHash": "17770758516688495068"
}
},
"parameters": {
Expand Down Expand Up @@ -526,7 +529,6 @@
"enabledForDiskEncryption": true,
"enabledForTemplateDeployment": true,
"enableRbacAuthorization": true,
"enablePurgeProtection": true,
"publicNetworkAccess": "enabled",
"sku": {
"family": "A",
Expand Down Expand Up @@ -672,7 +674,7 @@
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "10286514074548439078"
"templateHash": "18372681746235366113"
}
},
"parameters": {
Expand All @@ -688,7 +690,7 @@
},
"acrSku": {
"type": "string",
"defaultValue": "Premium",
"defaultValue": "Basic",
"metadata": {
"description": "Provide a tier of your Azure Container Registry."
}
Expand All @@ -709,25 +711,6 @@
"name": "[parameters('acrSku')]"
},
"properties": {
"adminUserEnabled": true,
"dataEndpointEnabled": false,
"networkRuleBypassOptions": "AzureServices",
"networkRuleSet": {
"defaultAction": "Allow"
},
"policies": {
"quarantinePolicy": {
"status": "disabled"
},
"retentionPolicy": {
"status": "enabled",
"days": 7
},
"trustPolicy": {
"status": "disabled",
"type": "Notary"
}
},
"publicNetworkAccess": "Enabled",
"zoneRedundancy": "Disabled"
}
Expand Down Expand Up @@ -1655,7 +1638,7 @@
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "15815884747026956332"
"templateHash": "1111747132207169107"
}
},
"parameters": {
Expand Down Expand Up @@ -2392,23 +2375,23 @@
"value": "[parameters('containerAppApiEndpoint')]"
},
{
"name": "APP_MSAL_AUTH_CLIENT_ID",
"name": "APP_WEB_CLIENT_ID",
"value": "<APP_REGISTRATION_CLIENTID>"
},
{
"name": "APP_MSAL_AUTH_AUTHORITY",
"name": "APP_WEB_AUTHORITY",
"value": "[format('{0}/{1}', environment().authentication.loginEndpoint, tenant().tenantId)]"
},
{
"name": "APP_MSAL_AUTH_SCOPE",
"name": "APP_WEB_SCOPE",
"value": "<FRONTEND_API_SCOPE>"
},
{
"name": "APP_MSAL_TOKEN_SCOPE",
"name": "APP_API_SCOPE",
"value": "<BACKEND_API_SCOPE>"
},
{
"name": "APP_ISLOGS_ENABLED",
"name": "APP_CONSOLE_LOG_ENABLED",
"value": "false"
}
]
Expand Down Expand Up @@ -3178,7 +3161,7 @@
"_generator": {
"name": "bicep",
"version": "0.34.44.8038",
"templateHash": "15815884747026956332"
"templateHash": "1111747132207169107"
}
},
"parameters": {
Expand Down Expand Up @@ -3915,23 +3898,23 @@
"value": "[parameters('containerAppApiEndpoint')]"
},
{
"name": "APP_MSAL_AUTH_CLIENT_ID",
"name": "APP_WEB_CLIENT_ID",
"value": "<APP_REGISTRATION_CLIENTID>"
},
{
"name": "APP_MSAL_AUTH_AUTHORITY",
"name": "APP_WEB_AUTHORITY",
"value": "[format('{0}/{1}', environment().authentication.loginEndpoint, tenant().tenantId)]"
},
{
"name": "APP_MSAL_AUTH_SCOPE",
"name": "APP_WEB_SCOPE",
"value": "<FRONTEND_API_SCOPE>"
},
{
"name": "APP_MSAL_TOKEN_SCOPE",
"name": "APP_API_SCOPE",
"value": "<BACKEND_API_SCOPE>"
},
{
"name": "APP_ISLOGS_ENABLED",
"name": "APP_CONSOLE_LOG_ENABLED",
"value": "false"
}
]
Expand Down
49 changes: 49 additions & 0 deletions infra/scripts/post_deployment.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Stop script on any error
$ErrorActionPreference = "Stop"

Write-Host "🔍 Fetching container app info from azd environment..."

# Load values from azd env
$CONTAINER_WEB_APP_NAME = azd env get-value CONTAINER_WEB_APP_NAME
$CONTAINER_WEB_APP_FQDN = azd env get-value CONTAINER_WEB_APP_FQDN

$CONTAINER_API_APP_NAME = azd env get-value CONTAINER_API_APP_NAME
$CONTAINER_API_APP_FQDN = azd env get-value CONTAINER_API_APP_FQDN

# Get subscription and resource group (assuming same for both)
$SUBSCRIPTION_ID = azd env get-value AZURE_SUBSCRIPTION_ID
$RESOURCE_GROUP = azd env get-value AZURE_RESOURCE_GROUP

# Construct Azure Portal URLs
$WEB_APP_PORTAL_URL = "https://portal.azure.com/#resource/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.App/containerApps/$CONTAINER_WEB_APP_NAME"
$API_APP_PORTAL_URL = "https://portal.azure.com/#resource/subscriptions/$SUBSCRIPTION_ID/resourceGroups/$RESOURCE_GROUP/providers/Microsoft.App/containerApps/$CONTAINER_API_APP_NAME"

# Get the current script's directory
$ScriptDir = $PSScriptRoot

# Navigate from infra/scripts → root → src/api/data/data.sh
$DataScriptPath = Join-Path $ScriptDir "..\..\src\ContentProcessorAPI\samples\schemas"

# Resolve to an absolute path
$FullPath = Resolve-Path $DataScriptPath

# Output
Write-Host ""
Write-Host "🧭 Web App Details:"
Write-Host " ✅ Name: $CONTAINER_WEB_APP_NAME"
Write-Host " 🌐 Endpoint: https://$CONTAINER_WEB_APP_FQDN"
Write-Host " 🔗 Portal URL: $WEB_APP_PORTAL_URL"

Write-Host ""
Write-Host "🧭 API App Details:"
Write-Host " ✅ Name: $CONTAINER_API_APP_NAME"
Write-Host " 🌐 Endpoint: https://$CONTAINER_API_APP_FQDN"
Write-Host " 🔗 Portal URL: $API_APP_PORTAL_URL"

Write-Host ""
Write-Host "📦 Follow Next steps to import Schemas:"
Write-Host "👉 Run the following commands in your terminal:"
$CurrentPath = Get-Location
Write-Host ""
Write-Host " cd $FullPath"
Write-Host " ./register_schema.ps1 https://$CONTAINER_API_APP_FQDN/schemavault/ schema_info_ps1.json"
Loading
Loading