From d01492f333a93ee57dd8df59a1fd00a0133c9fd3 Mon Sep 17 00:00:00 2001 From: User Name Date: Mon, 11 Oct 2021 20:25:06 +1300 Subject: [PATCH 1/4] Add Bicep file and starting workflow --- .github/workflows/workflow.yml | 27 +++++++++++ deploy/main.bicep | 88 ++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) create mode 100644 .github/workflows/workflow.yml create mode 100644 deploy/main.bicep diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..d7e07e3 --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,27 @@ +name: learn-github-actions + +on: + push: + branches: + - main + paths: + - 'deploy/**' + +env: + AZURE_RESOURCEGROUP_NAME: ToyWebsite + ENVIRONMENT_TYPE: Test + +jobs: + deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + - uses: azure/arm-deploy@v1 + with: + deploymentName: ${{ github.run_number }} + resourceGroupName: ${{ env.AZURE_RESOURCEGROUP_NAME }} + template: ./deploy/main.bicep + parameters: environmentType=${{ env.ENVIRONMENT_TYPE }} diff --git a/deploy/main.bicep b/deploy/main.bicep new file mode 100644 index 0000000..aa4364c --- /dev/null +++ b/deploy/main.bicep @@ -0,0 +1,88 @@ +@description('The location into which your Azure resources should be deployed.') +param location string = resourceGroup().location + +@description('Select the type of environment you want to provision. Allowed values are Production and Test.') +@allowed([ + 'Production' + 'Test' +]) +param environmentType string + +@description('A unique suffix to add to resource names that need to be globally unique.') +@maxLength(13) +param resourceNameSuffix string = uniqueString(resourceGroup().id) + +param storageAccountNameParam string = uniqueString(resourceGroup().id) + +// Define the names for resources. +var appServiceAppName = 'toy-website-${resourceNameSuffix}' +var appServicePlanName = 'toy-website' +var applicationInsightsName = 'toywebsite' +var storageAccountName = 'mystorageresourceNameSuffix' + +// Define the SKUs for each component based on the environment type. +var environmentConfigurationMap = { + Production: { + appServicePlan: { + sku: { + name: 'S1' + capacity: 1 + } + } + } + Test: { + appServicePlan: { + sku: { + name: 'F1' + } + } + } +} + +resource appServicePlan 'Microsoft.Web/serverfarms@2021-01-15' = { + name: appServicePlanName + location: location + sku: environmentConfigurationMap[environmentType].appServicePlan.sku +} + +resource appServiceApp 'Microsoft.Web/sites@2021-01-15' = { + name: appServiceAppName + location: location + properties: { + serverFarmId: appServicePlan.id + siteConfig: { + appSettings: [ + { + name: 'APPINSIGHTS_INSTRUMENTATIONKEY' + value: applicationInsights.properties.InstrumentationKey + } + { + name: 'APPLICATIONINSIGHTS_CONNECTION_STRING' + value: applicationInsights.properties.ConnectionString + } + ] + } + } +} + +resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = { + name: applicationInsightsName + location: location + kind: 'web' + properties: { + Application_Type: 'web' + Request_Source: 'rest' + Flow_Type: 'Bluefield' + } +} + +resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = { + name: storageAccountName + location: location + kind: 'StorageV2' + sku: { + name: 'Standard_LRS' + } +} + +output appServiceAppHostName string = appServiceApp.properties.defaultHostName From ecdba6bb5ef87b4a9171bc507dd5bc81f584010a Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Thu, 14 Oct 2021 16:30:07 +0200 Subject: [PATCH 2/4] Update workflow.yml --- .github/workflows/workflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d7e07e3..6ebc4f9 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -6,6 +6,7 @@ on: - main paths: - 'deploy/**' + workflow_dispatch: env: AZURE_RESOURCEGROUP_NAME: ToyWebsite From 1ac6904c58e81c1af24e2a992484828af77e8d71 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 15 Oct 2021 10:23:26 +0200 Subject: [PATCH 3/4] Leanr module uses ToyWebsiteTest (for now) --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6ebc4f9..e2a5af4 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -9,7 +9,7 @@ on: workflow_dispatch: env: - AZURE_RESOURCEGROUP_NAME: ToyWebsite + AZURE_RESOURCEGROUP_NAME: ToyWebsiteTest ENVIRONMENT_TYPE: Test jobs: From c42a29c7f8b1b84451ecd60d9567631a7a5e3f21 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 15 Oct 2021 10:44:25 +0200 Subject: [PATCH 4/4] learn module works on push --- .github/workflows/workflow.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index e2a5af4..32f986b 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -4,9 +4,6 @@ on: push: branches: - main - paths: - - 'deploy/**' - workflow_dispatch: env: AZURE_RESOURCEGROUP_NAME: ToyWebsiteTest