Skip to content

Commit

Permalink
adjusted setup script and deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasSirotek committed Nov 17, 2023
1 parent e67bf36 commit 73ac651
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 19 deletions.
30 changes: 29 additions & 1 deletion .azure/bicep/main.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ var environmentConfigurationMap = {
tier: 'Basic'
}
}
storageAccount: {
sku: {
name: 'Standard_LRS'
}
type: {
name: 'StorageV2'
}
}
}

Expand All @@ -48,10 +55,13 @@ var logAnalyticsWorkspaceName = 'log-${projectName}-${environmentAbbreviation}'
var applicationInsightsName = 'appi-${projectName}-${environmentAbbreviation}'
var sqlServerName = 'sql-${projectName}-${resourceNameSuffix}-${environmentAbbreviation}'
var sqlDatabaseName = '${projectName}-${environmentAbbreviation}'
var storageAccount = 'sa-${projectName}-${environmentAbbreviation}'

// Define the SKUs for each component based on the environment type.
var appServicePlanSku = environmentConfigurationMap[environmentName].appServicePlan.sku
var sqlDatabaseSku = environmentConfigurationMap[environmentName].sqlDatabase.sku
var storageAccountSku = environmentConfigurationMap[environmentName].storageAccount.sku
var storageAccountType = environmentConfigurationMap[environmentName].storageAccount.type

resource logAnalyticsWorkspace 'Microsoft.OperationalInsights/workspaces@2020-10-01' = {
name: logAnalyticsWorkspaceName
Expand Down Expand Up @@ -139,7 +149,7 @@ resource appServiceApp 'Microsoft.Web/sites@2021-01-15' = {
httpsOnly: true
siteConfig: {
healthCheckPath: '/health'
netFrameworkVersion: 'v7.0'
netFrameworkVersion: 'v8.0'
appSettings: [
{
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
Expand Down Expand Up @@ -265,6 +275,23 @@ resource sqlServer_FirewallRule 'Microsoft.Sql/servers/firewallRules@2021-02-01-
}
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2022-09-01' = {
name: storageAccountName
location: location
sku: {
name: storageAccountSku
}
kind: storageAccountType
identity: {
type: 'SystemAssigned'
}
}

resource blobStorage 'Microsoft.Storage/storageAccounts/blobServices@2022-09-01' = {
name: 'default'
parent: storageAccount
}

resource sqlDatabase_DiagnosticSettings 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview' = {
scope: sqlDatabase
name: 'sqlDatabaseDiagnosticSettings'
Expand Down Expand Up @@ -329,3 +356,4 @@ output appServiceAppName string = appServiceApp.name
output appServiceAppHostName string = appServiceApp.properties.defaultHostName
output sqlServerFullyQualifiedDomainName string = sqlServer.properties.fullyQualifiedDomainName
output sqlDatabaseName string = sqlDatabase.name
output storageAccount string = storageAccount.name
13 changes: 0 additions & 13 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,6 @@ jobs:
sqlAdministratorPassword=${{ secrets.AZURE_SQL_ADMINISTRATOR_PASSWORD }}
projectName=${{ vars.PROJECT_NAME }}
deploymentMode: Validate

- uses: azure/arm-deploy@v1
name: Run what-if
with:
failOnStdErr: false
resourceGroupName: ${{ vars.AZURE_RESOURCE_GROUP_NAME }}
template: ./.azure/bicep/main.bicep
parameters: >
environmentName=${{ inputs.environmentName }}
sqlAdministratorUsername=${{ vars.AZURE_SQL_ADMINISTRATOR_USERNAME }}
sqlAdministratorPassword=${{ secrets.AZURE_SQL_ADMINISTRATOR_PASSWORD }}
projectName=${{ vars.PROJECT_NAME }}
additionalArguments: --what-if

deploy:
needs: [ validate ]
Expand Down
2 changes: 0 additions & 2 deletions .scripts/environments.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
{
"Dev": "Development",
"Stg": "Staging",
"Prd": "Production"
}
4 changes: 1 addition & 3 deletions .scripts/setup.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if (-not $GitHubRepositoryName) {
}

if (-not $AzureLocation) {
$AzureLocation = "australiaeast"
$AzureLocation = "northeurope"
}

if (-not $AzureSubscriptionId) {
Expand Down Expand Up @@ -197,14 +197,12 @@ function SetEnvironmentVariablesAndSecrets {

SetVariables

foreach ($environment in $environments.PSObject.Properties) {
$environmentAbbr = $environment.Name
$environmentName = $environment.Value

CreateEnvironment $environmentName
$appId = CreateWorkloadIdentity $environmentAbbr $environmentName
CreateResourceGroup $environmentAbbr $appId
SetEnvironmentVariablesAndSecrets $environmentAbbr $environmentName $appId
}

Write-Host "✅ Done"

0 comments on commit 73ac651

Please sign in to comment.