Skip to content

Commit c737fab

Browse files
authored
Merge pull request #23 from githubabcs-devops/feature/update06
Add initial deployment configuration files for Azure web app
2 parents ea2b91b + 5b940ef commit c737fab

File tree

8 files changed

+518
-0
lines changed

8 files changed

+518
-0
lines changed

azure.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
name: webapp01
2+
metadata:
3+
template: webapp01
4+
description: Deployment configuration for webapp01
5+

infra/main.bicep

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// Bicep file to deploy a containerized web app to Azure
2+
3+
@description('The name of the Azure Container Registry')
4+
param acrName string
5+
6+
@description('The SKU of the Azure Container Registry')
7+
param acrSku string = 'Basic'
8+
9+
@description('The name of the App Service Plan')
10+
param appServicePlanName string
11+
12+
@description('The name of the Web App')
13+
param webAppName string
14+
15+
@description('The location for all resources')
16+
param location string
17+
18+
@description('The container image to deploy')
19+
param containerImage string
20+
21+
@description('The name of the Resource Group')
22+
param resourceGroupName string = 'rg-webapp01-dev'
23+
24+
// Create the resource group at the subscription level
25+
targetScope = 'subscription'
26+
27+
resource resourceGroup 'Microsoft.Resources/resourceGroups@2021-04-01' = {
28+
name: resourceGroupName
29+
location: location
30+
}
31+
32+
// Deploy resources within the resource group
33+
module resourcesInRG './resources.bicep' = {
34+
name: 'deployResourcesInRG'
35+
scope: resourceGroup
36+
params: {
37+
acrName: acrName
38+
acrSku: acrSku
39+
appServicePlanName: appServicePlanName
40+
webAppName: webAppName
41+
location: location
42+
containerImage: containerImage
43+
}
44+
}

infra/main.parameters.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"acrName": {
6+
"value": "acrwebapp01dev"
7+
},
8+
"acrSku": {
9+
"value": "Basic"
10+
},
11+
"appServicePlanName": {
12+
"value": "aspwebapp01dev"
13+
},
14+
"webAppName": {
15+
"value": "webapp01dev"
16+
},
17+
"location": {
18+
"value": "canadacentral"
19+
},
20+
"containerImage": {
21+
"value": "acrwebapp01dev.azurecr.io/webapp01:latest"
22+
},
23+
"resourceGroupName": {
24+
"value": "rg-webapp01-dev"
25+
}
26+
}
27+
}

infra/resources.bicep

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
@description('The name of the Azure Container Registry')
2+
param acrName string
3+
4+
@description('The SKU of the Azure Container Registry')
5+
param acrSku string
6+
7+
@description('The name of the App Service Plan')
8+
param appServicePlanName string
9+
10+
@description('The name of the Web App')
11+
param webAppName string
12+
13+
@description('The location for all resources')
14+
param location string
15+
16+
@description('The container image to deploy')
17+
param containerImage string
18+
19+
// Deploy the Azure Container Registry
20+
resource acr 'Microsoft.ContainerRegistry/registries@2023-01-01-preview' = {
21+
name: acrName
22+
location: location
23+
sku: {
24+
name: acrSku
25+
}
26+
properties: {
27+
adminUserEnabled: true
28+
}
29+
}
30+
31+
// Deploy the App Service Plan
32+
resource appServicePlan 'Microsoft.Web/serverfarms@2024-04-01' = {
33+
name: appServicePlanName
34+
location: location
35+
sku: {
36+
name: 'S1'
37+
tier: 'Standard'
38+
}
39+
properties: {
40+
reserved: true // Indicates Linux
41+
}
42+
}
43+
44+
// Deploy the Web App
45+
resource webApp 'Microsoft.Web/sites@2024-04-01' = {
46+
name: webAppName
47+
location: location
48+
identity: {
49+
type: 'SystemAssigned'
50+
}
51+
tags: {
52+
'azd-service-name': webAppName
53+
}
54+
properties: {
55+
serverFarmId: appServicePlan.id
56+
siteConfig: {
57+
appSettings: [
58+
{
59+
name: 'DOCKER_REGISTRY_SERVER_URL'
60+
value: 'https://${acr.name}.azurecr.io'
61+
}
62+
{
63+
name: 'DOCKER_REGISTRY_SERVER_USERNAME'
64+
value: acr.properties.loginServer
65+
}
66+
{
67+
name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
68+
value: acr.listCredentials().passwords[0].value
69+
}
70+
{
71+
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
72+
value: 'false'
73+
}
74+
{
75+
name: 'DOCKER_CUSTOM_IMAGE_NAME'
76+
value: containerImage
77+
}
78+
]
79+
linuxFxVersion: 'DOCKER|${containerImage}' // Specify the container image
80+
}
81+
}
82+
}

samples/Dockerfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
FROM alpine:3.14.0
2+
RUN echo "testuser:x:10999:10999:,,,:/home/testuser:/bin/bash" >> /etc/passwd && echo "testuser::18761:0:99999:7:::" >> /etc/shadow

samples/insecure.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
let injection = "Hello, security vulnerabilities!";
2+
eval(`console.log(\"${injection}\");`);

samples/insecure.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Commented out sample to pass scanning
2+
#
3+
#import hashlib
4+
# print("I am very insecure. Bandit thinks so too.")
5+
# #B110
6+
# xs=[1,2,3,4,5,6,7,8]
7+
# try:
8+
# print(xs[7])
9+
# print(xs[8])
10+
# except: pass
11+
12+
# ys=[1, 2, None, None]
13+
# for y in ys:
14+
# try:
15+
# print(str(y+3)) #TypeErrors ahead
16+
# except: continue #not how to handle them
17+
18+
# #some imports
19+
# import telnetlib
20+
# import ftplib
21+
22+
# #B303 and B324
23+
# s = b"I am a string"
24+
# print("MD5: " +hashlib.md5(s).hexdigest())
25+
# print("SHA1: " +hashlib.sha1(s).hexdigest())
26+
# print("SHA256: " +hashlib.sha256(s).hexdigest())

0 commit comments

Comments
 (0)