From a9b524b1bcf1a389fde54e8c4131544427a24c2a Mon Sep 17 00:00:00 2001 From: Lukas Rottach <50323692+lrottach@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:16:28 +0200 Subject: [PATCH 1/4] feat: developed new module to deploy Azure Functions --- .../Microsoft.Web/functionapp.module.bicep | 131 ++++++++++++++++++ 1 file changed, 131 insertions(+) create mode 100644 deploy/modules/Microsoft.Web/functionapp.module.bicep diff --git a/deploy/modules/Microsoft.Web/functionapp.module.bicep b/deploy/modules/Microsoft.Web/functionapp.module.bicep new file mode 100644 index 0000000..45c36fc --- /dev/null +++ b/deploy/modules/Microsoft.Web/functionapp.module.bicep @@ -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 + } +} From 65e854fa8569f9e29c406372db8226d3daeed807 Mon Sep 17 00:00:00 2001 From: Lukas Rottach <50323692+lrottach@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:16:38 +0200 Subject: [PATCH 2/4] feat: added main to call module deployments --- deploy/main.bicep | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) create mode 100644 deploy/main.bicep diff --git a/deploy/main.bicep b/deploy/main.bicep new file mode 100644 index 0000000..aed035a --- /dev/null +++ b/deploy/main.bicep @@ -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 + } +} From d366087b29e1a2db057ce702f8b43e2197f5c92a Mon Sep 17 00:00:00 2001 From: Lukas Rottach <50323692+lrottach@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:16:51 +0200 Subject: [PATCH 3/4] feat: added dev environment deployment --- deploy/param.dev.bicepparam | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 deploy/param.dev.bicepparam diff --git a/deploy/param.dev.bicepparam b/deploy/param.dev.bicepparam new file mode 100644 index 0000000..829d720 --- /dev/null +++ b/deploy/param.dev.bicepparam @@ -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' From 3603ab18a4797006952b5f4584a4b728ae6b584d Mon Sep 17 00:00:00 2001 From: Lukas Rottach <50323692+lrottach@users.noreply.github.com> Date: Tue, 15 Aug 2023 15:17:00 +0200 Subject: [PATCH 4/4] feat: added prod environment deployment --- deploy/param.prod.bicepparam | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 deploy/param.prod.bicepparam diff --git a/deploy/param.prod.bicepparam b/deploy/param.prod.bicepparam new file mode 100644 index 0000000..39d59b1 --- /dev/null +++ b/deploy/param.prod.bicepparam @@ -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'