|
| 1 | +targetScope = 'resourceGroup' |
| 2 | + |
| 3 | +@minLength(1) |
| 4 | +@description('The name of the App Service Plan resource') |
| 5 | +param appServicePlanName string |
| 6 | + |
| 7 | +@minLength(1) |
| 8 | +@description('The name of the App Service resource') |
| 9 | +param appServiceName string |
| 10 | + |
| 11 | +@minLength(1) |
| 12 | +@description('The name of the test database to create') |
| 13 | +param databaseName string = 'tododb' |
| 14 | + |
| 15 | +@minLength(1) |
| 16 | +@description('Primary location for all resources') |
| 17 | +param location string = resourceGroup().location |
| 18 | + |
| 19 | +@description('The name of the deployment in azure.yaml') |
| 20 | +param serviceName string = 'todoservice' |
| 21 | + |
| 22 | +@description('The name of the SQL Server to create.') |
| 23 | +param sqlServerName string |
| 24 | + |
| 25 | +@description('Optional - the SQL Server administrator password. If not provided, the username will be \'appadmin\'.') |
| 26 | +param sqlAdminUsername string = 'appadmin' |
| 27 | + |
| 28 | +@secure() |
| 29 | +@description('Optional - SQL Server administrator password. If not provided, a random password will be generated.') |
| 30 | +param sqlAdminPassword string = newGuid() |
| 31 | + |
| 32 | +@description('The list of tags to apply to all resources.') |
| 33 | +param tags object = {} |
| 34 | + |
| 35 | +/*********************************************************************************/ |
| 36 | + |
| 37 | +resource azsql_server 'Microsoft.Sql/servers@2024-05-01-preview' existing = { |
| 38 | + name: sqlServerName |
| 39 | +} |
| 40 | + |
| 41 | +resource sqldb 'Microsoft.Sql/servers/databases@2024-05-01-preview' = { |
| 42 | + name: databaseName |
| 43 | + parent: azsql_server |
| 44 | + location: location |
| 45 | + tags: tags |
| 46 | + sku: { |
| 47 | + name: 'Basic' |
| 48 | + } |
| 49 | + properties: { |
| 50 | + collation: 'SQL_Latin1_General_CP1_CI_AS' |
| 51 | + maxSizeBytes: 1073741824 |
| 52 | + } |
| 53 | +} |
| 54 | + |
| 55 | +resource appsvc_plan 'Microsoft.Web/serverfarms@2024-04-01' = { |
| 56 | + name: appServicePlanName |
| 57 | + location: location |
| 58 | + tags: tags |
| 59 | + sku: { |
| 60 | + name: 'B1' |
| 61 | + capacity: 1 |
| 62 | + } |
| 63 | +} |
| 64 | + |
| 65 | +resource app_service 'Microsoft.Web/sites@2024-04-01' = { |
| 66 | + name: appServiceName |
| 67 | + location: location |
| 68 | + tags: union(tags, { |
| 69 | + 'azd-service-name': serviceName |
| 70 | + 'hidden-related:${appsvc_plan.id}': 'empty' |
| 71 | + }) |
| 72 | + properties: { |
| 73 | + httpsOnly: true |
| 74 | + serverFarmId: appsvc_plan.id |
| 75 | + siteConfig: { |
| 76 | + ftpsState: 'Disabled' |
| 77 | + minTlsVersion: '1.2' |
| 78 | + } |
| 79 | + } |
| 80 | + |
| 81 | + resource configLogs 'config' = { |
| 82 | + name: 'logs' |
| 83 | + properties: { |
| 84 | + applicationLogs: { fileSystem: { level: 'Verbose' } } |
| 85 | + detailedErrorMessages: { enabled: true } |
| 86 | + failedRequestsTracing: { enabled: true } |
| 87 | + httpLogs: { fileSystem: { retentionInMb: 35, retentionInDays: 3, enabled: true } } |
| 88 | + } |
| 89 | + } |
| 90 | + |
| 91 | + resource connectionStrings 'config' = { |
| 92 | + name: 'connectionstrings' |
| 93 | + properties: { |
| 94 | + DefaultConnection: { |
| 95 | + value: 'Data Source=tcp:${azsql_server.properties.fullyQualifiedDomainName},1433;Initial Catalog=${sqldb.name};User Id=${sqlAdminUsername};Password=${sqlAdminPassword};' |
| 96 | + type: 'SQLAzure' |
| 97 | + } |
| 98 | + } |
| 99 | + } |
| 100 | +} |
| 101 | + |
| 102 | +/*********************************************************************************/ |
| 103 | + |
| 104 | +output SERVICE_ENDPOINT string = 'https://${app_service.properties.defaultHostName}' |
0 commit comments