Skip to content

Commit 8ffc239

Browse files
Merge pull request #373 from microsoft/template-deployment
fix: Template deployment
2 parents c7def41 + 9868620 commit 8ffc239

File tree

8 files changed

+208
-242
lines changed

8 files changed

+208
-242
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,6 @@ __pycache__/
99
venv
1010
myenv
1111

12-
scriptsenv/
12+
scriptsenv/
13+
14+
scriptenv

README.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,12 @@ To change the azd parameters from the default values, follow the steps [here](./
192192
* This deployment will take *7-10 minutes* to provision the resources in your account and set up the solution with sample data.
193193
* If you get an error or timeout with deployment, changing the location can help, as there may be availability constraints for the resources.
194194
195-
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`.
195+
5. Once the deployment has completed successfully and you would like to use the sample data, run the bash command printed in the terminal. The bash command will look like the following:
196+
```shell
197+
./infra/scripts/process_sample_data.sh <Storage-Account-name> <Storgae-Account-container-name> <Key-Vault-name>
198+
```
199+
200+
6. 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`.
196201
197202
6. You can now delete the resources by running `azd down`, if you are done trying out the application.
198203
<!-- 6. You can now proceed to run the [development server](#development-server) to test the app locally, or if you are done trying out the app, you can delete the resources by running `azd down`. -->

azure.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,18 @@ hooks:
3131
run: |
3232
Write-Host "Web app URL: "
3333
Write-Host "$env:WEB_APP_URL" -ForegroundColor Cyan
34+
Write-Host "`nIf you want to use the Sample Data, run the following command in the Bash terminal to process it:"
35+
Write-Host "bash ./infra/scripts/process_sample_data.sh $env:STORAGE_ACCOUNT_NAME $env:STORAGE_CONTAINER_NAME $env:KEY_VAULT_NAME" -ForegroundColor Cyan
3436
shell: pwsh
3537
continueOnError: false
3638
interactive: true
3739
posix:
3840
run: |
3941
echo "Web app URL: "
4042
echo $WEB_APP_URL
43+
echo ""
44+
echo "If you want to use the Sample Data, run the following command in the terminal to process it:"
45+
echo "bash ./infra/scripts/process_sample_data.sh $STORAGE_ACCOUNT_NAME $STORAGE_CONTAINER_NAME $KEY_VAULT_NAME"
4146
shell: sh
4247
continueOnError: false
4348
interactive: true

infra/main.bicep

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,12 @@ module cosmosDBModule 'deploy_cosmos_db.bicep' = {
424424
}
425425
scope: resourceGroup(resourceGroup().name)
426426
}
427+
// output copykbfiles string = './infra/scripts/copy_kb_files.sh ${storageAccount.outputs.storageName} ${storageAccount.outputs.storageContainer} ${managedIdentityModule.outputs.managedIdentityOutput.clientId}'
428+
// output createindex string = './infra/scripts/run_create_index_scripts.sh ${kvault.outputs.keyvaultName} ${managedIdentityModule.outputs.managedIdentityOutput.clientId}'
429+
430+
output STORAGE_ACCOUNT_NAME string = storageAccount.outputs.storageName
431+
output STORAGE_CONTAINER_NAME string = storageAccount.outputs.storageContainer
432+
output KEY_VAULT_NAME string = kvault.outputs.keyvaultName
427433

428434

429435
// //========== Deployment script to upload sample data ========== //
@@ -452,21 +458,21 @@ module cosmosDBModule 'deploy_cosmos_db.bicep' = {
452458
// dependsOn:[keyVault,uploadFiles]
453459
// }
454460

455-
//========== Deployment script to upload sample data ========== //
456-
module uploadFiles 'deploy_post_deployment_scripts.bicep' = {
457-
name : 'deploy_post_deployment_scripts'
458-
params:{
459-
solutionName: solutionPrefix
460-
solutionLocation: secondaryLocation
461-
baseUrl: baseUrl
462-
storageAccountName: storageAccount.outputs.storageName
463-
containerName: storageAccount.outputs.storageContainer
464-
managedIdentityObjectId:managedIdentityModule.outputs.managedIdentityOutput.id
465-
managedIdentityClientId:managedIdentityModule.outputs.managedIdentityOutput.clientId
466-
keyVaultName:aifoundry.outputs.keyvaultName
467-
logAnalyticsWorkspaceResourceName: aifoundry.outputs.logAnalyticsWorkspaceResourceName
468-
}
469-
}
461+
// //========== Deployment script to upload sample data ========== //
462+
// module uploadFiles 'deploy_post_deployment_scripts.bicep' = {
463+
// name : 'deploy_post_deployment_scripts'
464+
// params:{
465+
// solutionName: solutionPrefix
466+
// solutionLocation: secondaryLocation
467+
// baseUrl: baseUrl
468+
// storageAccountName: storageAccount.outputs.storageName
469+
// containerName: storageAccount.outputs.storageContainer
470+
// managedIdentityObjectId:managedIdentityModule.outputs.managedIdentityOutput.id
471+
// managedIdentityClientId:managedIdentityModule.outputs.managedIdentityOutput.clientId
472+
// keyVaultName:aifoundry.outputs.keyvaultName
473+
// logAnalyticsWorkspaceResourceName: aifoundry.outputs.logAnalyticsWorkspaceResourceName
474+
// }
475+
// }
470476

471477

472478
// resource CosmosDB 'Microsoft.DocumentDB/databaseAccounts@2023-04-15' = {

infra/main.json

Lines changed: 22 additions & 200 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
"metadata": {
55
"_generator": {
66
"name": "bicep",
7-
"version": "0.34.44.8038",
8-
"templateHash": "745056846550767942"
7+
"version": "0.33.93.31351",
8+
"templateHash": "2424049160506179064"
99
}
1010
},
1111
"parameters": {
@@ -150,8 +150,8 @@
150150
"metadata": {
151151
"_generator": {
152152
"name": "bicep",
153-
"version": "0.34.44.8038",
154-
"templateHash": "16854919160820907978"
153+
"version": "0.33.93.31351",
154+
"templateHash": "5719315788994459005"
155155
}
156156
},
157157
"parameters": {
@@ -243,8 +243,8 @@
243243
"metadata": {
244244
"_generator": {
245245
"name": "bicep",
246-
"version": "0.34.44.8038",
247-
"templateHash": "998804936838864872"
246+
"version": "0.33.93.31351",
247+
"templateHash": "16444845925569233096"
248248
}
249249
},
250250
"parameters": {
@@ -383,8 +383,8 @@
383383
"metadata": {
384384
"_generator": {
385385
"name": "bicep",
386-
"version": "0.34.44.8038",
387-
"templateHash": "15569997416548251984"
386+
"version": "0.33.93.31351",
387+
"templateHash": "627756007451802146"
388388
}
389389
},
390390
"parameters": {
@@ -981,8 +981,8 @@
981981
"metadata": {
982982
"_generator": {
983983
"name": "bicep",
984-
"version": "0.34.44.8038",
985-
"templateHash": "4051638923493896337"
984+
"version": "0.33.93.31351",
985+
"templateHash": "12863612675732383951"
986986
}
987987
},
988988
"parameters": {
@@ -1210,8 +1210,8 @@
12101210
"metadata": {
12111211
"_generator": {
12121212
"name": "bicep",
1213-
"version": "0.34.44.8038",
1214-
"templateHash": "4077975888118623954"
1213+
"version": "0.33.93.31351",
1214+
"templateHash": "6455788440385967919"
12151215
}
12161216
},
12171217
"parameters": {
@@ -1696,8 +1696,8 @@
16961696
"metadata": {
16971697
"_generator": {
16981698
"name": "bicep",
1699-
"version": "0.34.44.8038",
1700-
"templateHash": "6611317231290784098"
1699+
"version": "0.33.93.31351",
1700+
"templateHash": "16935405490916431865"
17011701
}
17021702
},
17031703
"parameters": {
@@ -1874,198 +1874,20 @@
18741874
"dependsOn": [
18751875
"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_keyvault')]"
18761876
]
1877-
},
1878-
{
1879-
"type": "Microsoft.Resources/deployments",
1880-
"apiVersion": "2022-09-01",
1881-
"name": "deploy_post_deployment_scripts",
1882-
"properties": {
1883-
"expressionEvaluationOptions": {
1884-
"scope": "inner"
1885-
},
1886-
"mode": "Incremental",
1887-
"parameters": {
1888-
"solutionName": {
1889-
"value": "[variables('solutionPrefix')]"
1890-
},
1891-
"solutionLocation": {
1892-
"value": "[parameters('secondaryLocation')]"
1893-
},
1894-
"baseUrl": {
1895-
"value": "[variables('baseUrl')]"
1896-
},
1897-
"storageAccountName": {
1898-
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_storage_account'), '2022-09-01').outputs.storageName.value]"
1899-
},
1900-
"containerName": {
1901-
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_storage_account'), '2022-09-01').outputs.storageContainer.value]"
1902-
},
1903-
"managedIdentityObjectId": {
1904-
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_managed_identity'), '2022-09-01').outputs.managedIdentityOutput.value.id]"
1905-
},
1906-
"managedIdentityClientId": {
1907-
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_managed_identity'), '2022-09-01').outputs.managedIdentityOutput.value.clientId]"
1908-
},
1909-
"keyVaultName": {
1910-
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_ai_foundry'), '2022-09-01').outputs.keyvaultName.value]"
1911-
},
1912-
"logAnalyticsWorkspaceResourceName": {
1913-
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_ai_foundry'), '2022-09-01').outputs.logAnalyticsWorkspaceResourceName.value]"
1914-
}
1915-
},
1916-
"template": {
1917-
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
1918-
"contentVersion": "1.0.0.0",
1919-
"metadata": {
1920-
"_generator": {
1921-
"name": "bicep",
1922-
"version": "0.34.44.8038",
1923-
"templateHash": "17578272684671627358"
1924-
}
1925-
},
1926-
"parameters": {
1927-
"solutionName": {
1928-
"type": "string",
1929-
"metadata": {
1930-
"description": "Solution Name"
1931-
}
1932-
},
1933-
"solutionLocation": {
1934-
"type": "string",
1935-
"metadata": {
1936-
"description": "Specifies the location for resources."
1937-
}
1938-
},
1939-
"baseUrl": {
1940-
"type": "string"
1941-
},
1942-
"managedIdentityObjectId": {
1943-
"type": "string"
1944-
},
1945-
"managedIdentityClientId": {
1946-
"type": "string"
1947-
},
1948-
"storageAccountName": {
1949-
"type": "string"
1950-
},
1951-
"containerName": {
1952-
"type": "string"
1953-
},
1954-
"containerAppName": {
1955-
"type": "string",
1956-
"defaultValue": "[format('ca-{0}', parameters('solutionName'))]"
1957-
},
1958-
"environmentName": {
1959-
"type": "string",
1960-
"defaultValue": "[format('cae-{0}', parameters('solutionName'))]"
1961-
},
1962-
"imageName": {
1963-
"type": "string",
1964-
"defaultValue": "python:3.11-alpine"
1965-
},
1966-
"setupCopyKbFiles": {
1967-
"type": "string",
1968-
"defaultValue": "[format('{0}infra/scripts/copy_kb_files.sh', parameters('baseUrl'))]"
1969-
},
1970-
"setupCreateIndexScriptsUrl": {
1971-
"type": "string",
1972-
"defaultValue": "[format('{0}infra/scripts/run_create_index_scripts.sh', parameters('baseUrl'))]"
1973-
},
1974-
"keyVaultName": {
1975-
"type": "string"
1976-
},
1977-
"logAnalyticsWorkspaceResourceName": {
1978-
"type": "string"
1979-
}
1980-
},
1981-
"resources": [
1982-
{
1983-
"type": "Microsoft.App/managedEnvironments",
1984-
"apiVersion": "2022-03-01",
1985-
"name": "[parameters('environmentName')]",
1986-
"location": "[parameters('solutionLocation')]",
1987-
"properties": {
1988-
"zoneRedundant": false,
1989-
"appLogsConfiguration": {
1990-
"destination": "log-analytics",
1991-
"logAnalyticsConfiguration": {
1992-
"customerId": "[reference(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceResourceName')), '2020-10-01').customerId]",
1993-
"sharedKey": "[listKeys(resourceId('Microsoft.OperationalInsights/workspaces', parameters('logAnalyticsWorkspaceResourceName')), '2020-10-01').primarySharedKey]"
1994-
}
1995-
}
1996-
}
1997-
},
1998-
{
1999-
"type": "Microsoft.App/containerApps",
2000-
"apiVersion": "2022-03-01",
2001-
"name": "[parameters('containerAppName')]",
2002-
"location": "[parameters('solutionLocation')]",
2003-
"identity": {
2004-
"type": "UserAssigned",
2005-
"userAssignedIdentities": {
2006-
"[format('{0}', parameters('managedIdentityObjectId'))]": {}
2007-
}
2008-
},
2009-
"properties": {
2010-
"managedEnvironmentId": "[resourceId('Microsoft.App/managedEnvironments', parameters('environmentName'))]",
2011-
"configuration": {
2012-
"ingress": null,
2013-
"activeRevisionsMode": "Single"
2014-
},
2015-
"template": {
2016-
"scale": {
2017-
"minReplicas": 1,
2018-
"maxReplicas": 1
2019-
},
2020-
"containers": [
2021-
{
2022-
"name": "[parameters('containerAppName')]",
2023-
"image": "[parameters('imageName')]",
2024-
"resources": {
2025-
"cpu": 2,
2026-
"memory": "4.0Gi"
2027-
},
2028-
"command": [
2029-
"/bin/sh",
2030-
"-c",
2031-
"[format('mkdir -p /scripts && apk add --no-cache curl bash jq py3-pip gcc musl-dev libffi-dev openssl-dev python3-dev && pip install --upgrade azure-cli && apk add --no-cache --virtual .build-deps build-base unixodbc-dev && curl -s -o msodbcsql18_18.4.1.1-1_amd64.apk https://download.microsoft.com/download/7/6/d/76de322a-d860-4894-9945-f0cc5d6a45f8/msodbcsql18_18.4.1.1-1_amd64.apk && curl -s -o mssql-tools18_18.4.1.1-1_amd64.apk https://download.microsoft.com/download/7/6/d/76de322a-d860-4894-9945-f0cc5d6a45f8/mssql-tools18_18.4.1.1-1_amd64.apk && apk add --allow-untrusted msodbcsql18_18.4.1.1-1_amd64.apk && apk add --allow-untrusted mssql-tools18_18.4.1.1-1_amd64.apk && curl -s -o /scripts/copy_kb_files.sh {0} && chmod +x /scripts/copy_kb_files.sh && sh -x /scripts/copy_kb_files.sh {1} {2} {3} {4} && curl -s -o /scripts/run_create_index_scripts.sh {5} && chmod +x /scripts/run_create_index_scripts.sh && sh -x /scripts/run_create_index_scripts.sh {6} {7} {8} && apk add --no-cache ca-certificates less ncurses-terminfo-base krb5-libs libgcc libintl libssl3 libstdc++ tzdata userspace-rcu zlib icu-libs curl && apk -X https://dl-cdn.alpinelinux.org/alpine/edge/main add --no-cache lttng-ust openssh-client && echo \"Container app setup completed successfully.\"', parameters('setupCopyKbFiles'), parameters('storageAccountName'), parameters('containerName'), parameters('baseUrl'), parameters('managedIdentityClientId'), parameters('setupCreateIndexScriptsUrl'), parameters('baseUrl'), parameters('keyVaultName'), parameters('managedIdentityClientId'))]"
2032-
],
2033-
"env": [
2034-
{
2035-
"name": "STORAGE_ACCOUNT_NAME",
2036-
"value": "[parameters('storageAccountName')]"
2037-
},
2038-
{
2039-
"name": "CONTAINER_NAME",
2040-
"value": "[parameters('containerName')]"
2041-
},
2042-
{
2043-
"name": "APPSETTING_WEBSITE_SITE_NAME",
2044-
"value": "DUMMY"
2045-
}
2046-
]
2047-
}
2048-
]
2049-
}
2050-
},
2051-
"dependsOn": [
2052-
"[resourceId('Microsoft.App/managedEnvironments', parameters('environmentName'))]"
2053-
]
2054-
}
2055-
]
2056-
}
2057-
},
2058-
"dependsOn": [
2059-
"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_ai_foundry')]",
2060-
"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_managed_identity')]",
2061-
"[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_storage_account')]"
2062-
]
20631877
}
20641878
],
20651879
"outputs": {
20661880
"WEB_APP_URL": {
20671881
"type": "string",
20681882
"value": "[reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_app_service'), '2022-09-01').outputs.webAppUrl.value]"
1883+
},
1884+
"copykbfiles": {
1885+
"type": "string",
1886+
"value": "[format('./infra/scripts/copy_kb_files.sh {0} {1} {2}', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_storage_account'), '2022-09-01').outputs.storageName.value, reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_storage_account'), '2022-09-01').outputs.storageContainer.value, reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_managed_identity'), '2022-09-01').outputs.managedIdentityOutput.value.clientId)]"
1887+
},
1888+
"createindex": {
1889+
"type": "string",
1890+
"value": "[format('./infra/scripts/run_create_index_scripts.sh {0} {1}', reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_keyvault'), '2022-09-01').outputs.keyvaultName.value, reference(extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', subscription().subscriptionId, resourceGroup().name), 'Microsoft.Resources/deployments', 'deploy_managed_identity'), '2022-09-01').outputs.managedIdentityOutput.value.clientId)]"
20691891
}
20701892
}
20711893
}

0 commit comments

Comments
 (0)