Skip to content

Commit 55d6bda

Browse files
author
Prakash
committed
Added application deployment
1 parent 3bbcd88 commit 55d6bda

File tree

2 files changed

+127
-1
lines changed

2 files changed

+127
-1
lines changed

.github/workflows/deploy.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Azure Bicep
2+
3+
on:
4+
workflow_dispatch
5+
6+
env:
7+
targetEnv: dev
8+
9+
jobs:
10+
build-and-deploy:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
pages: write
15+
id-token: write
16+
steps:
17+
# Checkout code
18+
- uses: actions/checkout@main
19+
20+
# Log into Azure
21+
- uses: azure/[email protected]
22+
with:
23+
client-id: ${{ secrets.AZURE_CLIENT_ID }}
24+
tenant-id: ${{ secrets.AZURE_TENANT_ID }}
25+
subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
26+
enable-AzPSSession: true
27+
28+
# Deploy ARM template
29+
- name: Run ARM deploy
30+
uses: azure/arm-deploy@v1
31+
with:
32+
subscriptionId: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
33+
resourceGroupName: ${{ secrets.AZURE_RG }}
34+
template: ./src/InfrastructureAsCode/main.bicep
35+
parameters: environment=${{ env.targetEnv }}

src/InfrastructureAsCode/main.bicep

Lines changed: 92 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,95 @@ var registrySku = 'Standard'
1414
var imageName = 'techexcel/dotnetcoreapp'
1515
var startupCommand = ''
1616

17-
// TODO: complete this script
17+
// Create a log analytics workspace
18+
resource logAnalytics 'Microsoft.OperationalInsights/workspaces@2023-09-01' = {
19+
name: logAnalyticsName
20+
location: location
21+
properties: {
22+
sku: {
23+
name: 'PerGB2018'
24+
}
25+
retentionInDays: 90
26+
workspaceCapping: {
27+
dailyQuotaGb: 2
28+
}
29+
}
30+
}
31+
32+
//Create an application insights
33+
resource appInsights 'Microsoft.Insights/components@2020-02-02' = {
34+
name: appInsightsName
35+
location: location
36+
kind: 'web'
37+
properties: {
38+
Application_Type: 'web'
39+
WorkspaceResourceId: logAnalytics.id
40+
}
41+
}
42+
43+
// Create a container registry
44+
resource containerRegistry 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = {
45+
name: registryName
46+
location: location
47+
sku: {
48+
name: registrySku
49+
}
50+
properties: {
51+
adminUserEnabled: true
52+
}
53+
}
54+
55+
// Create an app service plan
56+
resource appServicePlan 'Microsoft.Web/serverfarms@2023-12-01' = {
57+
name: appServicePlanName
58+
location: location
59+
kind: 'linux'
60+
sku: {
61+
name: sku
62+
}
63+
properties: {
64+
reserved: true
65+
}
66+
}
67+
68+
// Create a web app
69+
resource webApp 'Microsoft.Web/sites@2023-12-01' = {
70+
name: webAppName
71+
location: location
72+
properties: {
73+
serverFarmId: appServicePlan.id
74+
httpsOnly: true
75+
siteConfig: {
76+
linuxFxVersion: 'DOCKER|${containerRegistry.name}.azurecr.io/${uniqueString(resourceGroup().id)}/${imageName}'
77+
http20Enabled: true
78+
minTlsVersion: '1.2'
79+
appCommandLine: startupCommand
80+
appSettings: [
81+
{
82+
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
83+
value: appInsights.properties.InstrumentationKey
84+
}
85+
{
86+
name: 'DOCKER_REGISTRY_SERVER_URL'
87+
value: 'https://${containerRegistry.name}.azurecr.io'
88+
}
89+
{
90+
name: 'DOCKER_REGISTRY_SERVER_USERNAME'
91+
value: containerRegistry.name
92+
}
93+
{
94+
name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
95+
value: containerRegistry.listCredentials().passwords[0].value
96+
}
97+
{
98+
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
99+
value: 'false'
100+
}
101+
]
102+
}
103+
}
104+
}
105+
106+
output application_name string = webApp.name
107+
output application_url string = webApp.properties.hostNames[0]
108+
output container_registry_name string = containerRegistry.name

0 commit comments

Comments
 (0)