Skip to content

Instantly share code, notes, and snippets.

@scottsauber
Last active August 25, 2024 13:50
Show Gist options
  • Save scottsauber/38c9fceb811c2d4b58b74ceefa4a2269 to your computer and use it in GitHub Desktop.
Save scottsauber/38c9fceb811c2d4b58b74ceefa4a2269 to your computer and use it in GitHub Desktop.
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
}
}
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
}
}
- 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
@VPuzdriak
Copy link

Would be better to put use a param for appName in main.bicep.

@scottsauberlt
Copy link

@VPuzdriak yep definitely if you were reusing this Bicep module across different applications.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment