-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added azd compatible live testing (#189)
- Loading branch information
1 parent
f0fab0b
commit 68fb075
Showing
16 changed files
with
643 additions
and
378 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/Azure/azure-dev/main/schemas/v1.0/azure.yaml.json | ||
|
||
## | ||
## This AZD template will create all the resources necessary to | ||
## test the Community Toolkit/Datasync libraries, plus deploy an | ||
## app service (on free tier) that talks to the AzSQL service | ||
## for the TODO Sample Service | ||
## | ||
|
||
name: communitytoolkit-datasync-test-services | ||
|
||
hooks: | ||
postprovision: | ||
posix: | ||
interactive: true | ||
shell: sh | ||
run: ./infra/scripts/write-runsettings.sh | ||
windows: | ||
interactive: true | ||
shell: pwsh | ||
run: ./infra/scripts/write-runsettings.ps1 | ||
|
||
predown: | ||
posix: | ||
interactive: true | ||
shell: sh | ||
run: ./infra/scripts/remove-runsettings.sh | ||
windows: | ||
interactive: true | ||
shell: pwsh | ||
run: ./infra/scripts/remove-runsettings.ps1 | ||
|
||
services: | ||
todoservice: | ||
language: csharp | ||
project: ./samples/datasync-server/src/Sample.Datasync.Server | ||
host: appservice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
targetScope = 'subscription' | ||
|
||
@minLength(1) | ||
@maxLength(64) | ||
@description('Name of the the environment which is used to generate a short unique hash used in all resources.') | ||
param environmentName string | ||
|
||
@minLength(1) | ||
@description('Primary location for all resources') | ||
param location string | ||
|
||
@description('Id of the user or app to assign application roles') | ||
param principalId string = '' | ||
|
||
@description('Optional - the SQL Server administrator password. If not provided, the username will be \'appadmin\'.') | ||
param sqlAdminUsername string = 'appadmin' | ||
|
||
@secure() | ||
@description('Optional - SQL Server administrator password. If not provided, a random password will be generated.') | ||
param sqlAdminPassword string = newGuid() | ||
|
||
/*********************************************************************************/ | ||
|
||
var resourceToken = toLower(uniqueString(subscription().id, environmentName, location)) | ||
var tags = { 'azd-env-name': environmentName } | ||
|
||
/*********************************************************************************/ | ||
|
||
resource rg 'Microsoft.Resources/resourceGroups@2024-07-01' = { | ||
name: 'rg-${environmentName}' | ||
location: location | ||
tags: tags | ||
} | ||
|
||
module resources './resources.bicep' = { | ||
name: 'resources' | ||
scope: rg | ||
params: { | ||
location: location | ||
tags: tags | ||
principalId: principalId | ||
resourceToken: resourceToken | ||
serviceName: 'todoservice' | ||
sqlAdminUsername: sqlAdminUsername | ||
sqlAdminPassword: sqlAdminPassword | ||
} | ||
} | ||
|
||
/*********************************************************************************/ | ||
|
||
output AZSQL_CONNECTION_STRING string = resources.outputs.AZSQL_CONNECTIONSTRING | ||
output PGSQL_CONNECTION_STRING string = resources.outputs.PGSQL_CONNECTIONSTRING | ||
output COSMOS_CONNECTION_STRING string = resources.outputs.COSMOS_CONNECTIONSTRING | ||
output SERVICE_ENDPOINT string = resources.outputs.SERVICE_ENDPOINT |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"environmentName": { | ||
"value": "${AZURE_ENV_NAME}" | ||
}, | ||
"location": { | ||
"value": "${AZURE_LOCATION}" | ||
}, | ||
"principalId": { | ||
"value": "${AZURE_PRINCIPAL_ID}" | ||
}, | ||
"sqlAdminUsername": { | ||
"value": "appadmin" | ||
}, | ||
"sqlAdminPassword": { | ||
"value": "$(secretOrRandomPassword)" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
targetScope = 'resourceGroup' | ||
|
||
@minLength(1) | ||
@description('The name of the App Service Plan resource') | ||
param appServicePlanName string | ||
|
||
@minLength(1) | ||
@description('The name of the App Service resource') | ||
param appServiceName string | ||
|
||
@minLength(1) | ||
@description('The name of the test database to create') | ||
param databaseName string = 'tododb' | ||
|
||
@minLength(1) | ||
@description('Primary location for all resources') | ||
param location string = resourceGroup().location | ||
|
||
@description('The name of the deployment in azure.yaml') | ||
param serviceName string = 'todoservice' | ||
|
||
@description('The name of the SQL Server to create.') | ||
param sqlServerName string | ||
|
||
@description('Optional - the SQL Server administrator password. If not provided, the username will be \'appadmin\'.') | ||
param sqlAdminUsername string = 'appadmin' | ||
|
||
@secure() | ||
@description('Optional - SQL Server administrator password. If not provided, a random password will be generated.') | ||
param sqlAdminPassword string = newGuid() | ||
|
||
@description('The list of tags to apply to all resources.') | ||
param tags object = {} | ||
|
||
/*********************************************************************************/ | ||
|
||
resource azsql_server 'Microsoft.Sql/servers@2024-05-01-preview' existing = { | ||
name: sqlServerName | ||
} | ||
|
||
resource sqldb 'Microsoft.Sql/servers/databases@2024-05-01-preview' = { | ||
name: databaseName | ||
parent: azsql_server | ||
location: location | ||
tags: tags | ||
sku: { | ||
name: 'Basic' | ||
} | ||
properties: { | ||
collation: 'SQL_Latin1_General_CP1_CI_AS' | ||
maxSizeBytes: 1073741824 | ||
} | ||
} | ||
|
||
resource appsvc_plan 'Microsoft.Web/serverfarms@2024-04-01' = { | ||
name: appServicePlanName | ||
location: location | ||
tags: tags | ||
sku: { | ||
name: 'B1' | ||
capacity: 1 | ||
} | ||
} | ||
|
||
resource app_service 'Microsoft.Web/sites@2024-04-01' = { | ||
name: appServiceName | ||
location: location | ||
tags: union(tags, { | ||
'azd-service-name': serviceName | ||
'hidden-related:${appsvc_plan.id}': 'empty' | ||
}) | ||
properties: { | ||
httpsOnly: true | ||
serverFarmId: appsvc_plan.id | ||
siteConfig: { | ||
ftpsState: 'Disabled' | ||
minTlsVersion: '1.2' | ||
} | ||
} | ||
|
||
resource configLogs 'config' = { | ||
name: 'logs' | ||
properties: { | ||
applicationLogs: { fileSystem: { level: 'Verbose' } } | ||
detailedErrorMessages: { enabled: true } | ||
failedRequestsTracing: { enabled: true } | ||
httpLogs: { fileSystem: { retentionInMb: 35, retentionInDays: 3, enabled: true } } | ||
} | ||
} | ||
|
||
resource connectionStrings 'config' = { | ||
name: 'connectionstrings' | ||
properties: { | ||
DefaultConnection: { | ||
value: 'Data Source=tcp:${azsql_server.properties.fullyQualifiedDomainName},1433;Initial Catalog=${sqldb.name};User Id=${sqlAdminUsername};Password=${sqlAdminPassword};' | ||
type: 'SQLAzure' | ||
} | ||
} | ||
} | ||
} | ||
|
||
/*********************************************************************************/ | ||
|
||
output SERVICE_ENDPOINT string = 'https://${app_service.properties.defaultHostName}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
targetScope = 'resourceGroup' | ||
|
||
@description('The list of firewall rules to install') | ||
param firewallRules FirewallRule[] = [ | ||
{ startIpAddress: '0.0.0.0', endIpAddress: '0.0.0.0' } | ||
] | ||
|
||
@minLength(1) | ||
@description('The name of the test database to create') | ||
param databaseName string = 'unittests' | ||
|
||
@minLength(1) | ||
@description('Primary location for all resources') | ||
param location string = resourceGroup().location | ||
|
||
@description('The name of the SQL Server to create.') | ||
param sqlServerName string | ||
|
||
@description('Optional - the SQL Server administrator password. If not provided, the username will be \'appadmin\'.') | ||
param sqlAdminUsername string = 'appadmin' | ||
|
||
@secure() | ||
@description('Optional - SQL Server administrator password. If not provided, a random password will be generated.') | ||
param sqlAdminPassword string = newGuid() | ||
|
||
@description('The list of tags to apply to all resources.') | ||
param tags object = {} | ||
|
||
/*********************************************************************************/ | ||
|
||
resource azsql_server 'Microsoft.Sql/servers@2024-05-01-preview' = { | ||
name: sqlServerName | ||
location: location | ||
tags: tags | ||
properties: { | ||
version: '12.0' | ||
minimalTlsVersion: '1.2' | ||
publicNetworkAccess: 'Enabled' | ||
administratorLogin: sqlAdminUsername | ||
administratorLoginPassword: sqlAdminPassword | ||
} | ||
|
||
resource fw 'firewallRules' = [ | ||
for fwRule in firewallRules: { | ||
name: '${fwRule.startIpAddress}-${fwRule.endIpAddress}' | ||
properties: { | ||
startIpAddress: fwRule.startIpAddress | ||
endIpAddress: fwRule.endIpAddress | ||
} | ||
} | ||
] | ||
} | ||
|
||
resource azsql_database 'Microsoft.Sql/servers/databases@2024-05-01-preview' = { | ||
name: databaseName | ||
parent: azsql_server | ||
location: location | ||
tags: tags | ||
sku: { | ||
name: 'Basic' | ||
tier: 'Basic' | ||
} | ||
properties: { | ||
collation: 'SQL_Latin1_General_CP1_CI_AS' | ||
} | ||
} | ||
|
||
/*********************************************************************************/ | ||
|
||
#disable-next-line outputs-should-not-contain-secrets | ||
output AZSQL_CONNECTIONSTRING string = 'Data Source=tcp:${azsql_server.properties.fullyQualifiedDomainName},1433;Initial Catalog=${azsql_database.name};User Id=${azsql_server.properties.administratorLogin}@${azsql_server.properties.fullyQualifiedDomainName};Password=${sqlAdminPassword};Encrypt=True;TrustServerCertificate=False' | ||
|
||
/*********************************************************************************/ | ||
|
||
type FirewallRule = { | ||
startIpAddress: string | ||
endIpAddress: string | ||
} |
Oops, something went wrong.