|
| 1 | +param storageLocation string |
| 2 | +param environment string |
| 3 | +@secure() |
| 4 | +param postgresDBPassword string |
| 5 | + |
| 6 | +resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2023-09-01' = { |
| 7 | + name: 'template-fastapi-react-${environment}-logWorkspace' |
| 8 | + location: storageLocation |
| 9 | + properties: { |
| 10 | + publicNetworkAccessForQuery: 'Enabled' |
| 11 | + publicNetworkAccessForIngestion: 'Enabled' |
| 12 | + forceCmkForQuery: false |
| 13 | + sku: { |
| 14 | + name: 'pergb2018' |
| 15 | + } |
| 16 | + retentionInDays: environment == 'prod' ? 730 : 90 |
| 17 | + workspaceCapping: { |
| 18 | + dailyQuotaGb: environment == 'prod' ? 10 : 1 |
| 19 | + } |
| 20 | + } |
| 21 | +} |
| 22 | + |
| 23 | +resource appInsight 'Microsoft.Insights/components@2020-02-02' = { |
| 24 | + name: 'template-fastapi-react-${environment}-logs' |
| 25 | + location: storageLocation |
| 26 | + kind: 'web' |
| 27 | + properties: { |
| 28 | + Application_Type: 'web' |
| 29 | + Flow_Type: 'Bluefield' |
| 30 | + IngestionMode: 'LogAnalytics' |
| 31 | + publicNetworkAccessForIngestion: 'Enabled' |
| 32 | + publicNetworkAccessForQuery: 'Enabled' |
| 33 | + Request_Source: 'rest' |
| 34 | + RetentionInDays: environment == 'prod' ? 730 : 90 |
| 35 | + WorkspaceResourceId: logAnalyticsWorkspace.id |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +resource queryPack 'Microsoft.OperationalInsights/queryPacks@2019-09-01' = { |
| 40 | + location: storageLocation |
| 41 | + name: 'template-fastapi-react-${environment}-queryPack' |
| 42 | + properties: { |
| 43 | + |
| 44 | + } |
| 45 | +} |
| 46 | + |
| 47 | + |
| 48 | +resource keyVault 'Microsoft.KeyVault/vaults@2023-07-01' = { |
| 49 | + name: 'template-fastapi-react-${environment}-keyVault' |
| 50 | + location: storageLocation |
| 51 | + properties: { |
| 52 | + tenantId: '3aa4a235-b6e2-48d5-9195-7fcf05b459b0' |
| 53 | + softDeleteRetentionInDays: 30 |
| 54 | + enabledForDeployment: true |
| 55 | + enableSoftDelete: true |
| 56 | + accessPolicies: [] // Grant each user explicit access after the vault has been created |
| 57 | + sku: { |
| 58 | + name: 'standard' |
| 59 | + family: 'A' |
| 60 | + } |
| 61 | + publicNetworkAccess: 'Disabled' |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +resource databasePassword 'Microsoft.KeyVault/vaults/secrets@2024-04-01-preview' = { |
| 66 | + parent: keyVault |
| 67 | + name: 'template-fastapi-react-database-${environment}-password' |
| 68 | + properties: { |
| 69 | + value: postgresDBPassword |
| 70 | + } |
| 71 | +} |
| 72 | + |
| 73 | + |
| 74 | +resource sqlServer 'Microsoft.DBforPostgreSQL/flexibleServers@2023-12-01-preview' = { |
| 75 | + name: 'template-fastapi-react-${environment}-database' |
| 76 | + location: storageLocation |
| 77 | + sku: { |
| 78 | + name: 'Standard_B1ms' |
| 79 | + tier: 'Burstable' |
| 80 | + } |
| 81 | + properties: { |
| 82 | + version: '16' |
| 83 | + administratorLogin: 'template-fastapi-react' |
| 84 | + administratorLoginPassword: postgresDBPassword |
| 85 | + maintenanceWindow: { |
| 86 | + customWindow: 'Enabled' |
| 87 | + dayOfWeek: 0 |
| 88 | + startHour: 3 |
| 89 | + startMinute: 18 |
| 90 | + } |
| 91 | + network:{publicNetworkAccess: 'Enabled'} |
| 92 | + highAvailability: { |
| 93 | + mode: 'Disabled' |
| 94 | + } |
| 95 | + storage: { |
| 96 | + storageSizeGB: 64 |
| 97 | + type: 'Premium_LRS' |
| 98 | + } |
| 99 | + backup: { |
| 100 | + backupRetentionDays: 7 |
| 101 | + geoRedundantBackup: 'Disabled' |
| 102 | + } |
| 103 | + } |
| 104 | +} |
| 105 | + |
| 106 | +resource template-fastapi-reactDatabase 'Microsoft.DBforPostgreSQL/flexibleServers/databases@2023-12-01-preview' = { |
| 107 | + name: 'template-fastapi-react' |
| 108 | + parent: sqlServer |
| 109 | + properties: { |
| 110 | + charset: 'UTF8' |
| 111 | + collation: 'en_US.utf8' |
| 112 | + } |
| 113 | +} |
| 114 | + |
| 115 | + |
| 116 | +resource databaseAllowRadixConnection 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2023-12-01-preview' = { |
| 117 | + name: 'allow-radix-connection' |
| 118 | + parent: sqlServer |
| 119 | + properties: { |
| 120 | + startIpAddress: '52.178.214.192' |
| 121 | + endIpAddress: '52.178.214.199' |
| 122 | + } |
| 123 | +} |
| 124 | + |
| 125 | +resource databaseAllowRadixConnection2 'Microsoft.DBforPostgreSQL/flexibleServers/firewallRules@2023-12-01-preview' = { |
| 126 | + name: 'allow-radix-connection2' |
| 127 | + parent: sqlServer |
| 128 | + properties: { |
| 129 | + startIpAddress: '137.135.191.80' |
| 130 | + endIpAddress: '137.135.191.95' |
| 131 | + } |
| 132 | +} |
| 133 | + |
| 134 | +resource sendEmailActionGroup 'Microsoft.Insights/actionGroups@2023-01-01' = { |
| 135 | + name: 'send-email-action-group' |
| 136 | + location: 'global' |
| 137 | + properties: { |
| 138 | + groupShortName: 'ErrorNotify' |
| 139 | + enabled: true |
| 140 | + emailReceivers: [ |
| 141 | + { |
| 142 | + name: 'Notify Eirik by email_-EmailAction-' |
| 143 | + |
| 144 | + useCommonAlertSchema: false |
| 145 | + } |
| 146 | + ] |
| 147 | + } |
| 148 | +} |
| 149 | + |
| 150 | + |
| 151 | +resource metricAlerts 'Microsoft.Insights/metricAlerts@2018-03-01' = { |
| 152 | + name: 'Send email on error in template-fastapi-react' |
| 153 | + location: 'global' |
| 154 | + properties: { |
| 155 | + description: 'When an error is detected in template-fastapi-react, an email is dispatched' |
| 156 | + severity: 1 |
| 157 | + enabled: true |
| 158 | + scopes: [ |
| 159 | + appInsight.id |
| 160 | + ] |
| 161 | + evaluationFrequency: 'PT1H' |
| 162 | + windowSize: 'PT1H' |
| 163 | + criteria: { |
| 164 | + allOf: [ |
| 165 | + { |
| 166 | + threshold: 0 |
| 167 | + name: 'Metric1' |
| 168 | + metricNamespace: 'microsoft.insights/components' |
| 169 | + metricName: 'exceptions/count' |
| 170 | + operator: 'GreaterThan' |
| 171 | + timeAggregation: 'Count' |
| 172 | + skipMetricValidation: false |
| 173 | + criterionType: 'StaticThresholdCriterion' |
| 174 | + } |
| 175 | + ] |
| 176 | + 'odata.type': 'Microsoft.Azure.Monitor.SingleResourceMultipleMetricCriteria' |
| 177 | + } |
| 178 | + autoMitigate: false |
| 179 | + targetResourceType: 'microsoft.insights/components' |
| 180 | + targetResourceRegion: 'norwayeast' |
| 181 | + actions: [ |
| 182 | + { |
| 183 | + actionGroupId: sendEmailActionGroup.id |
| 184 | + } |
| 185 | + ] |
| 186 | + } |
| 187 | +} |
0 commit comments