Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .github/workflows/step-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ jobs:
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}

# Run Bicep deployment to provision nevironment resources if needed
- name: Run Bicep
run: |
az deployment group create \
--name ${{ inputs.env }}-deployment-${{ github.run_number }} \
--template-file infrastructure/main.bicep \
--resource-group ${{ inputs.resource_group_name }} \
--verbose

# Deploy to Azure Web apps
- name: 'Deploy to Azure App Service'
uses: azure/webapps-deploy@v2
Expand Down
70 changes: 70 additions & 0 deletions infrastructure/appservice.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
param appName string
@allowed(['dev', 'prod'])
param environment string
param location string

// This is reused between the App Service and the Slot
var appServiceProperties = {
serverFarmId: appServicePlan.id
httpsOnly: true
siteConfig: {
http20Enabled: true
linuxFxVersion: 'DOTNETCORE|8.0'
alwaysOn: true
ftpsState: 'Disabled'
minTlsVersion: '1.2'
webSocketsEnabled: true
requestTracingEnabled: true
detailedErrorLoggingEnabled: true
httpLoggingEnabled: true
}
}

resource appServicePlan 'Microsoft.Web/serverfarms@2022-09-01' = {
name: 'asp-${appName}-${environment}'
location: location
sku: {
name: 'P0V3'
}
kind: 'linux'
properties: {
reserved: true
}
}

resource appService 'Microsoft.Web/sites@2022-09-01' = {
name: 'app-${appName}-${environment}'
location: location
identity: {
type: 'SystemAssigned'
}
properties: appServiceProperties
}

resource appSettings 'Microsoft.Web/sites/config@2022-09-01' = {
name: 'appsettings'
kind: 'string'
parent: appService
properties: {
ASPNETCORE_ENVIRONMENT: environment
}
}

resource appServiceSlot 'Microsoft.Web/sites/slots@2022-09-01' = {
location: location
parent: appService
name: 'slot'
identity: {
type: 'SystemAssigned'
}
properties: appServiceProperties
}

resource appServiceSlotSetting 'Microsoft.Web/sites/slots/config@2022-09-01' = {
name: 'appsettings'
kind: 'string'
parent: appServiceSlot
properties: {
ASPNETCORE_ENVIRONMENT: environment
}
}
15 changes: 15 additions & 0 deletions infrastructure/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
param location string = 'eastus'
@allowed(['dev', 'prod'])
param environment string

// Normally I like creating the Resource Groups too in Bicep, but for this workshop that would require more permissions to give people than I'd like
targetScope = 'resourceGroup'

module app './appservice.bicep' = {
name: 'appservice'
params: {
appName: 'dometrain-github-actions-scottsauber'
environment: environment
location: location
}
}