dotnet-podcasts/deploy/Services/api.deployment.json

408 lines
13 KiB
JSON

{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.4.1008.15138",
"templateHash": "15926170708320974222"
}
},
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
},
"imageTag": {
"type": "string"
},
"acrPassword": {
"type": "secureString"
},
"acrLogin": {
"type": "string"
},
"acrLoginServer": {
"type": "string"
},
"serverName": {
"type": "string"
},
"sqlDBName": {
"type": "string",
"defaultValue": "Podcast"
},
"administratorLogin": {
"type": "string"
},
"storageAccountName": {
"type": "string"
},
"kubernetesEnvName": {
"type": "string"
},
"workspaceName": {
"type": "string"
},
"administratorLoginPassword": {
"type": "secureString"
}
},
"functions": [],
"variables": {
"workspaceId": "[resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspaceName'))]",
"kubernetesEnvId": "[resourceId('Microsoft.App/managedEnvironments', parameters('kubernetesEnvName'))]",
"kubernetesEnvLocation": "canadacentral",
"podcastDbConnectionString": "[format('Server=tcp:{0}.database.windows.net,1433;Initial Catalog={1};Persist Security Info=False;User ID={2};Password={3};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;', parameters('serverName'), parameters('sqlDBName'), parameters('administratorLogin'), parameters('administratorLoginPassword'))]",
"podcastApiImage": "[format('{0}/podcastapi:{1}', parameters('acrLoginServer'), parameters('imageTag'))]",
"podcastUpdaterImage": "[format('{0}/podcastupdaterworker:{1}', parameters('acrLoginServer'), parameters('imageTag'))]",
"podcastIngestionWorkerImage": "[format('{0}/podcastingestionworker:{1}', parameters('acrLoginServer'), parameters('imageTag'))]",
"imagesStorage": "[format('https://{0}.blob.core.windows.net/covers/', parameters('storageAccountName'))]",
"deployIngestion": false
},
"resources": [
{
"type": "Microsoft.Sql/servers",
"apiVersion": "2020-02-02-preview",
"name": "[parameters('serverName')]",
"location": "[parameters('location')]",
"properties": {
"administratorLogin": "[parameters('administratorLogin')]",
"administratorLoginPassword": "[parameters('administratorLoginPassword')]"
}
},
{
"type": "Microsoft.Sql/servers/databases",
"apiVersion": "2020-08-01-preview",
"name": "[format('{0}/{1}', parameters('serverName'), parameters('sqlDBName'))]",
"location": "[parameters('location')]",
"sku": {
"name": "Basic",
"tier": "Basic",
"capacity": 5
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
]
},
{
"condition": "[true()]",
"type": "Microsoft.Sql/servers/firewallrules",
"apiVersion": "2014-04-01-preview",
"name": "[format('{0}/{1}', parameters('serverName'), 'AllowAllWindowsAzureIps')]",
"location": "[resourceGroup().location]",
"properties": {
"endIpAddress": "0.0.0.0",
"startIpAddress": "0.0.0.0"
},
"dependsOn": [
"[resourceId('Microsoft.Sql/servers', parameters('serverName'))]"
]
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[parameters('storageAccountName')]",
"location": "[parameters('location')]",
"kind": "StorageV2",
"sku": {
"name": "Standard_LRS"
},
"properties": {
"accessTier": "Hot"
}
},
{
"type": "Microsoft.Storage/storageAccounts/queueServices/queues",
"apiVersion": "2021-06-01",
"name": "[format('{0}/default/feed-queue', parameters('storageAccountName'))]",
"dependsOn": [
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
]
},
{
"type": "Microsoft.OperationalInsights/workspaces",
"apiVersion": "2020-08-01",
"name": "[parameters('workspaceName')]",
"location": "[parameters('location')]",
"properties": {
"sku": {
"name": "PerGB2018"
},
"retentionInDays": 30,
"features": {
"searchVersion": 1,
"legacy": 0,
"enableLogAccessUsingOnlyResourcePermissions": true
}
}
},
{
"type": "Microsoft.App/managedEnvironments",
"apiVersion": "2022-01-01-preview",
"name": "[parameters('kubernetesEnvName')]",
"location": "[variables('kubernetesEnvLocation')]",
"tags": {},
"properties": {
"type": "Managed",
"appLogsConfiguration": {
"destination": "log-analytics",
"logAnalyticsConfiguration": {
"customerId": "[reference(variables('workspaceId'), '2015-03-20').customerId]",
"sharedKey": "[listKeys(variables('workspaceId'), '2015-11-01-preview').primarySharedKey]"
}
}
},
"dependsOn": [
"[resourceId('Microsoft.OperationalInsights/workspaces', parameters('workspaceName'))]"
]
},
{
"type": "Microsoft.App/containerApps",
"apiVersion": "2022-01-01-preview",
"name": "podcastapica",
"location": "[variables('kubernetesEnvLocation')]",
"kind": "containerapp",
"properties": {
"managedEnvironmentId": "[variables('kubernetesEnvId')]",
"configuration": {
"activeRevisionsMode": "single",
"ingress": {
"external": true,
"targetPort": 80
},
"registries": [
{
"server": "[parameters('acrLoginServer')]",
"username": "[parameters('acrLogin')]",
"passwordSecretRef": "acr-password"
}
],
"secrets": [
{
"name": "feedqueue",
"value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix=core.windows.net;AccountKey={1}', parameters('storageAccountName'), listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
},
{
"name": "podcastdb",
"value": "[variables('podcastDbConnectionString')]"
},
{
"name": "acr-password",
"value": "[parameters('acrPassword')]"
}
]
},
"template": {
"containers": [
{
"image": "[variables('podcastApiImage')]",
"name": "podcastapi",
"resources": {
"cpu": 1,
"memory": "2Gi"
},
"env": [
{
"name": "ConnectionStrings__FeedQueue",
"secretRef": "feedqueue"
},
{
"name": "ConnectionStrings__PodcastDb",
"secretRef": "podcastdb"
},
{
"name": "Features__FeedIngestion",
"value": "[format('{0}', variables('deployIngestion'))]"
}
]
}
],
"dapr": {
"enabled": false
},
"scale": {
"minReplicas": 1,
"maxReplicas": 5,
"rules": [
{
"name": "httpscalingrule",
"http": {
"metadata": {
"concurrentRequests": "20"
}
}
}
]
}
}
},
"tags": {},
"dependsOn": [
"[resourceId('Microsoft.App/managedEnvironments', parameters('kubernetesEnvName'))]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('serverName'), parameters('sqlDBName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
]
},
{
"condition": "[variables('deployIngestion')]",
"type": "Microsoft.App/containerApps",
"apiVersion": "2022-01-01-preview",
"name": "podcastingestionca",
"location": "[variables('kubernetesEnvLocation')]",
"kind": "containerapp",
"properties": {
"managedEnvironmentId": "[variables('kubernetesEnvId')]",
"configuration": {
"activeRevisionsMode": "single",
"registries": [
{
"server": "[parameters('acrLoginServer')]",
"username": "[parameters('acrLogin')]",
"passwordSecretRef": "acr-password"
}
],
"secrets": [
{
"name": "feedqueue",
"value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix=core.windows.net;AccountKey={1}', parameters('storageAccountName'), listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
},
{
"name": "podcastdb",
"value": "[variables('podcastDbConnectionString')]"
},
{
"name": "acr-password",
"value": "[parameters('acrPassword')]"
}
]
},
"template": {
"containers": [
{
"image": "[variables('podcastIngestionWorkerImage')]",
"name": "podcastingestion",
"resources": {
"cpu": 1,
"memory": "2Gi"
},
"env": [
{
"name": "ConnectionStrings__FeedQueue",
"secretRef": "feedqueue"
},
{
"name": "ConnectionStrings__PodcastDb",
"secretRef": "podcastdb"
}
]
}
],
"dapr": {
"enabled": false
},
"scale": {
"maxReplicas": 5,
"minReplicas": 0,
"rules": [
{
"name": "queue-scaling-rule",
"azureQueue": {
"queueName": "feed-queue",
"queueLength": 20,
"auth": [
{
"secretRef": "feedqueue",
"triggerParameter": "connection"
}
]
}
}
]
}
}
},
"tags": {},
"dependsOn": [
"[resourceId('Microsoft.App/managedEnvironments', parameters('kubernetesEnvName'))]",
"[resourceId('Microsoft.App/containerApps', 'podcastapica')]",
"[resourceId('Microsoft.Sql/servers/databases', parameters('serverName'), parameters('sqlDBName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
]
},
{
"type": "Microsoft.App/containerApps",
"apiVersion": "2022-01-01-preview",
"name": "podcastupdaterca",
"location": "[variables('kubernetesEnvLocation')]",
"kind": "containerapp",
"properties": {
"managedEnvironmentId": "[variables('kubernetesEnvId')]",
"configuration": {
"activeRevisionsMode": "single",
"registries": [
{
"server": "[parameters('acrLoginServer')]",
"username": "[parameters('acrLogin')]",
"passwordSecretRef": "acr-password"
}
],
"secrets": [
{
"name": "podcastdb",
"value": "[variables('podcastDbConnectionString')]"
},
{
"name": "acr-password",
"value": "[parameters('acrPassword')]"
}
]
},
"template": {
"containers": [
{
"image": "[variables('podcastUpdaterImage')]",
"name": "podcastupdater",
"resources": {
"cpu": 1,
"memory": "2Gi"
},
"env": [
{
"name": "ConnectionStrings__PodcastDb",
"secretRef": "podcastdb"
},
{
"name": "Storage__Images",
"value": "[variables('imagesStorage')]"
}
]
}
],
"dapr": {
"enabled": false
},
"scale": {
"minReplicas": 0,
"maxReplicas": 1
}
}
},
"tags": {},
"dependsOn": [
"[resourceId('Microsoft.App/managedEnvironments', parameters('kubernetesEnvName'))]",
"[resourceId('Microsoft.App/containerApps', 'podcastapica')]",
"[resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName'))]"
]
}
],
"outputs": {
"storageConnectionString": {
"type": "string",
"value": "[format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix=core.windows.net;AccountKey={1}', parameters('storageAccountName'), listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('storageAccountName')), '2019-06-01').keys[0].value)]"
}
}
}