Skip to content

Commit

Permalink
merge: pull request #18 from lrottach/feat/bicep-deployment
Browse files Browse the repository at this point in the history
feat: implemented bicep deployment
  • Loading branch information
lrottach authored Aug 16, 2023
2 parents 2344aed + 3603ab1 commit 8e35a50
Show file tree
Hide file tree
Showing 4 changed files with 218 additions and 0 deletions.
65 changes: 65 additions & 0 deletions deploy/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@


///////////////////////////////////////////////
//
// Type: Main
// Author: Lukas Rottach
// CreationDate: 15.08.2023
// Name: Azure Chronos Deployment
//
///////////////////////////////////////////////

////////////////////////////////
// Deployoment Scope
////////////////////////////////
targetScope = 'subscription'

////////////////////////////////
// Parameter Area
////////////////////////////////

// Deployment parameter
param deploymentLocation string
param rgName string

// Function parameter
param functionAppName string

@description('The language worker runtime to load in the function app.')
@allowed([
'dotnet'
'dotnet-isolated'
])
param runtime string

@allowed([
'v7.0'
'v6.0'
])
param dotnetVersion string

// Storage parameter
param storageName string

////////////////////////////////
// Resource Area
////////////////////////////////
resource rg 'Microsoft.Resources/resourceGroups@2022-09-01' = {
name: rgName
location: deploymentLocation
}

////////////////////////////////
// Module Area
////////////////////////////////
module func './modules/Microsoft.Web/functionapp.module.bicep' = {
scope: rg
name: 'deploy-${rg.name}'
params: {
deploymentLocation: deploymentLocation
dotnetVersion: dotnetVersion
functionAppName: functionAppName
runtime: runtime
storageName: storageName
}
}
131 changes: 131 additions & 0 deletions deploy/modules/Microsoft.Web/functionapp.module.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
///////////////////////////////////////////////
//
// Type: Module
// Author: Lukas Rottach
// CreationDate: 15.08.2023
// Name: Azure Function App
// Provider: Microsoft.Web
//
///////////////////////////////////////////////

////////////////////////////////
// Deployoment Scope
////////////////////////////////
targetScope = 'resourceGroup'

////////////////////////////////
// Parameter Area
////////////////////////////////

// Deployment parameter
param deploymentLocation string

// Function parameter
param functionAppName string

@description('The language worker runtime to load in the function app.')
@allowed([
'dotnet'
'dotnet-isolated'
])
param runtime string

@allowed([
'v7.0'
'v6.0'
])
param dotnetVersion string

// Storage parameter
param storageName string

////////////////////////////////
// Resource Area
////////////////////////////////

// Hosting Plan
resource asp 'Microsoft.Web/serverfarms@2022-09-01' = {
name: '${functionAppName}-asp1-we'
location: deploymentLocation
sku: {
name: 'Y1'
tier: 'Dynamic'
}
properties: {}
}

// Storage Account
resource sto 'Microsoft.Storage/storageAccounts@2023-01-01' = {
name: storageName
location: deploymentLocation
sku: {
name: 'Standard_LRS'
}
kind: 'StorageV2'
properties: {
supportsHttpsTrafficOnly: true
defaultToOAuthAuthentication: true
}
}

// Application Insights
resource appin 'Microsoft.Insights/components@2020-02-02' = {
name: '${functionAppName}-appin1-we'
location: deploymentLocation
kind: 'web'
properties: {
Application_Type: 'web'
Request_Source: 'rest'
}
}

// Azure Function App
resource func 'Microsoft.Web/sites@2022-09-01' = {
name: functionAppName
location: deploymentLocation
kind: 'functionapp'
identity: {
type: 'SystemAssigned'
}
properties: {
serverFarmId: asp.id
siteConfig: {
appSettings: [
{
name: 'AzureWebJobsStorage'
value: 'DefaultEndpointsProtocol=https;AccountName=${sto.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${sto.listKeys().keys[0].value}'
}
{
name: 'WEBSITE_CONTENTAZUREFILECONNECTIONSTRING'
value: 'DefaultEndpointsProtocol=https;AccountName=${sto.name};EndpointSuffix=${environment().suffixes.storage};AccountKey=${sto.listKeys().keys[0].value}'
}
{
name: 'WEBSITE_CONTENTSHARE'
value: toLower(functionAppName)
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~4'
}
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: appin.properties.InstrumentationKey
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: runtime
}
]
cors: {
allowedOrigins: [
'https://portal.azure.com'
]
}
netFrameworkVersion: dotnetVersion
use32BitWorkerProcess: true
ftpsState: 'FtpsOnly'
minTlsVersion: '1.2'
}
httpsOnly: true
}
}
11 changes: 11 additions & 0 deletions deploy/param.dev.bicepparam
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using 'main.bicep'

// Deployment Parameter
param deploymentLocation = 'West Europe'
param rgName = 'rg-dev-chronos1-we'

// Function Parameter
param functionAppName = 'azure-chronos-dev'
param storageName = 'devazchronossto1we'
param runtime = 'dotnet-isolated'
param dotnetVersion = 'v7.0'
11 changes: 11 additions & 0 deletions deploy/param.prod.bicepparam
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using 'main.bicep'

// Deployment Parameter
param deploymentLocation = 'West Europe'
param rgName = 'rg-prod-chronos1-we'

// Function Parameter
param functionAppName = 'azure-chronos'
param storageName = 'prodazchronossto1we'
param runtime = 'dotnet-isolated'
param dotnetVersion = 'v7.0'

0 comments on commit 8e35a50

Please sign in to comment.