Skip to content

adding azure files for app service deployment #349

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions azure/templates/pact-broker.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
targetScope = 'subscription'

@description('Function to help automatically concatenate a deployment name with a character limit of 65.')
func deploymentName(baseName string) string => take('${baseName}-${uniqueString(string(deployment()))}', 64)

@description('Name of environment')
param environment string

@description('Resource/Resource Group location')
param location string

@description('The tags attached to the resource')
param envTags object = {}

@description('Administrator login for PostgreSQL')
param administratorLogin string

@secure()
@description('Administrator password for PostgreSQL')
param postgresPassword string

@description('PostgreSQL server edition')
param serverEdition string

@description('PostgreSQL instance type')
param dbInstanceType string

@description('PostgreSQL version')
param version string

@description('PostgreSQL SKU size in GB')
param skuSizeGB int

@description('Docker image for Pact Broker')
param pactBrokerImageVersion string

// Joins the standard tags for your context with any custom tags passed in via the parameter file.
var tags = union(envTags, {
Owner: '{Inser Owner Here}'
Environment: environment
})

var resourceGroupName = '${environment}-pactbroker-rg'
//An Azure App service is a public facing resource and must be unique.
//Update the name as needed if you recieve an error that the name is already in use!
var pactBrokerAppName = '${environment}-pactbroker-app-01'
var pactBrokerAspName = '${environment}-pactbroker-asp-01'
var postgresName = '${environment}-pactbroker-postgres-01'
var urlHostName = '{Insert Custom URL here}'

// Creates the Resource Group for resources
module rg 'br:mcr.microsoft.com/bicep/avm/res/resources/resource-group:0.4.0' = {
name: deploymentName('rg-${resourceGroupName}')
scope: subscription()
params: {
name: resourceGroupName
location: location
tags: tags
}
}

// Deploy PostgreSQL Server
module postgres 'br:mcr.microsoft.com/bicep/avm/res/db-for-postgre-sql/flexible-server:0.3.0' = {
name: take('${postgresName}-${uniqueString(string(deployment()))}', 64)
scope: resourceGroup(resourceGroupName)
params: {
location: location
name: postgresName
administratorLogin: administratorLogin
administratorLoginPassword: postgresPassword
tier: serverEdition
skuName: dbInstanceType
version: version
storageSizeGB: skuSizeGB
passwordAuth: 'Enabled'
firewallRules: [
// Added to allows Access from Azure resources and services
{
name: 'AllowAllAzureServicesAndResourcesWithinAzureIps'
startIpAddress: '0.0.0.0'
endIpAddress: '0.0.0.0'
}
]
}
dependsOn: [
rg
]
}

//Deploy App Service Plan
module asp 'br:mcr.microsoft.com/bicep/avm/res/web/serverfarm:0.2.2' = {
name: take('${pactBrokerAspName}-${uniqueString(string(deployment()))}', 64)
scope: resourceGroup(resourceGroupName)
params: {
name: pactBrokerAspName
location: location
skuCapacity: 2
skuName: 'B1'
kind: 'Linux'
}
dependsOn: [
rg
]
}

//Deploy Linux Web App running PAct-Broker Container
module app 'br:mcr.microsoft.com/bicep/avm/res/web/site:0.9.0' = {
name: take('${pactBrokerAppName}-${uniqueString(string(deployment()))}', 64)
scope: resourceGroup(resourceGroupName)
params: {
name: pactBrokerAppName
location: location
kind: 'app,linux,container'
serverFarmResourceId: asp.outputs.resourceId
managedIdentities: {
systemAssigned: true
}
siteConfig: {
linuxFxVersion: 'DOCKER|pactfoundation/pact-broker:${pactBrokerImageVersion}'
appSettings: [
{
name: 'DOCKER_REGISTRY_SERVER_PASSWORD'
value: ''
}
{
name: 'DOCKER_REGISTRY_SERVER_URL'
value: 'https://index.docker.io'
}
{
name: 'DOCKER_REGISTRY_SERVER_USERNAME'
value: ''
}
{
name: 'PACT_BROKER_BASE_URL'
value: urlHostName
}
{
name: 'PACT_BROKER_DATABASE_ADAPTER'
value: 'postgres'
}
{
name: 'PACT_BROKER_DATABASE_HOST'
value: postgres.outputs.fqdn
}
{
name: 'PACT_BROKER_DATABASE_NAME'
value: 'postgres'
}
{
name: 'PACT_BROKER_DATABASE_PORT'
value: 5432
}
{
name: 'PACT_BROKER_DATABASE_USERNAME'
value: administratorLogin
}
{
name: 'PACT_BROKER_DATABASE_PASSWORD'
value: postgresPassword
}
{
name: 'PACT_BROKER_ENABLE_DIAGNOSTIC_ENDPOINTS'
value: true
}
{
name: 'PACT_BROKER_PORT'
value: 9292
}
{
name: 'PACT_BROKER_PUBLIC_HEARTBEAT'
value: true
}
{
name: 'WEBSITE_HEALTHCHECK_MAXPINGFAILURES'
value: 2
}
{
name: 'WEBSITE_HTTPLOGGING_RETENTION_DAYS'
value: 2
}
{
name: 'WEBSITES_ENABLE_APP_SERVICE_STORAGE'
value: false
}
{
name: 'WEBSITES_PORT'
value: 9292
}
]
}
}
dependsOn: [
rg
]
}
14 changes: 14 additions & 0 deletions azure/templates/parameters/pact-broker.bicepparam
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using '../pact-broker.bicep'

param environment = 'dev'
param location = 'eastus2'
param envTags = {
'Date Created': '20240926'
}
param postgresPassword = 'Password'
param serverEdition = 'GeneralPurpose'
param dbInstanceType = 'Standard_D4ds_v4'
param version = '13'
param skuSizeGB = 128
param pactBrokerImageVersion = '2.107.0.1'
param administratorLogin = 'pactbroker'
11 changes: 11 additions & 0 deletions azure/templates/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
This folder containes a bicep template with the following resources.
```
1. Resource Group to hold all resource
2. Postgres SQL Database
3. App Service Plan for the Web App
4. Web App runing linux
```

Each module block in the template poing to the Microsoft Bicep Module Repo, and uses Azure Verified Modules.

In the script folder, the azcli.ps1 file will contain azcli commands to perform a What-if and Create deployment.
18 changes: 18 additions & 0 deletions azure/templates/scripts/azcli.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
## Command to connect to your azure subscription
az login

## Command to set your subscription
#### NOTE, this is needed only if you have
#### more than one subscription available to your account.
az account set --subscription '{Insert subscription name or ID here}'

## Command to run a What-If deployment at the scope of the bicep template
#### NOTE, the templates are as a subscription level, which is why
#### the commands above are needed.
az deployment sub what-if --location '{Insert deployment locations here}' --template-file .\pact-broker.bicep --parmeters .\parameters\pact-broker.bicepparam

## Command to run a Create deployment at the scope of the bicep template
#### NOTE, the templates are as a subscription level, which is why
#### the commands above are needed.

az deployment sub create --location '{Insert deployment locations here}' --template-file .\pact-broker.bicep --parmeters .\parameters\pact-broker.bicepparam