Skip to content

Commit 67f8548

Browse files
User Namejohndowns
authored andcommitted
Add Bicep file and starting workflow
1 parent 0d5cc38 commit 67f8548

File tree

2 files changed

+116
-0
lines changed

2 files changed

+116
-0
lines changed

.github/workflows/workflow.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: deploy-toy-website-test
2+
concurrency: toy-company
3+
4+
on:
5+
push:
6+
branches:
7+
- main
8+
9+
env:
10+
AZURE_RESOURCEGROUP_NAME: ToyWebsite
11+
ENVIRONMENT_TYPE: Test
12+
13+
jobs:
14+
deploy:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v2
18+
- uses: azure/login@v1
19+
name: Sign in to Azure
20+
with:
21+
creds: ${{ secrets.AZURE_CREDENTIALS }}
22+
- uses: azure/arm-deploy@v1
23+
name: Deploy website
24+
with:
25+
deploymentName: ${{ github.run_number }}
26+
resourceGroupName: ${{ env.AZURE_RESOURCEGROUP_NAME }}
27+
template: ./deploy/main.bicep
28+
parameters: environmentType=${{ env.ENVIRONMENT_TYPE }}

deploy/main.bicep

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
@description('The location into which your Azure resources should be deployed.')
2+
param location string = resourceGroup().location
3+
4+
@description('Select the type of environment you want to provision. Allowed values are Production and Test.')
5+
@allowed([
6+
'Production'
7+
'Test'
8+
])
9+
param environmentType string
10+
11+
@description('A unique suffix to add to resource names that need to be globally unique.')
12+
@maxLength(13)
13+
param resourceNameSuffix string = uniqueString(resourceGroup().id)
14+
15+
param storageAccountNameParam string = uniqueString(resourceGroup().id)
16+
17+
// Define the names for resources.
18+
var appServiceAppName = 'toy-website-${resourceNameSuffix}'
19+
var appServicePlanName = 'toy-website'
20+
var applicationInsightsName = 'toywebsite'
21+
var storageAccountName = 'mystorageresourceNameSuffix'
22+
23+
// Define the SKUs for each component based on the environment type.
24+
var environmentConfigurationMap = {
25+
Production: {
26+
appServicePlan: {
27+
sku: {
28+
name: 'S1'
29+
capacity: 1
30+
}
31+
}
32+
}
33+
Test: {
34+
appServicePlan: {
35+
sku: {
36+
name: 'F1'
37+
}
38+
}
39+
}
40+
}
41+
42+
resource appServicePlan 'Microsoft.Web/serverfarms@2021-01-15' = {
43+
name: appServicePlanName
44+
location: location
45+
sku: environmentConfigurationMap[environmentType].appServicePlan.sku
46+
}
47+
48+
resource appServiceApp 'Microsoft.Web/sites@2021-01-15' = {
49+
name: appServiceAppName
50+
location: location
51+
properties: {
52+
serverFarmId: appServicePlan.id
53+
siteConfig: {
54+
appSettings: [
55+
{
56+
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
57+
value: applicationInsights.properties.InstrumentationKey
58+
}
59+
{
60+
name: 'APPLICATIONINSIGHTS_CONNECTION_STRING'
61+
value: applicationInsights.properties.ConnectionString
62+
}
63+
]
64+
}
65+
}
66+
}
67+
68+
resource applicationInsights 'Microsoft.Insights/components@2020-02-02' = {
69+
name: applicationInsightsName
70+
location: location
71+
kind: 'web'
72+
properties: {
73+
Application_Type: 'web'
74+
Request_Source: 'rest'
75+
Flow_Type: 'Bluefield'
76+
}
77+
}
78+
79+
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
80+
name: storageAccountName
81+
location: location
82+
kind: 'StorageV2'
83+
sku: {
84+
name: 'Standard_LRS'
85+
}
86+
}
87+
88+
output appServiceAppHostName string = appServiceApp.properties.defaultHostName

0 commit comments

Comments
 (0)