Skip to content

Commit

Permalink
Merge pull request #3 from nhsuk/azure-deployment
Browse files Browse the repository at this point in the history
Azure deployment
  • Loading branch information
prembonsall authored Apr 6, 2020
2 parents 7788cf8 + 5e81f76 commit 2171a4c
Show file tree
Hide file tree
Showing 2 changed files with 243 additions and 0 deletions.
187 changes: 187 additions & 0 deletions AzureResourceGroup/template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "String",
"allowedValues": [
"uksouth",
"ukwest"
]
},
"environment": {
"type": "String"
},
"functionAppName": {
"type": "String"
},
"hostingPlanSkuTier": {
"type": "String"
},
"hostingPlanSkuName": {
"type": "String"
},
"enableCORS": {
"type": "Bool"
},
"buildTag": {
"type": "String"
},
"expiresTag": {
"type": "String",
"defaultValue": "Never"
},
"ownerTag": {
"type": "String"
}
},
"variables": {
"locationAbbreviation": "[substring(parameters('location'), 0, 3)]",
"storageAccountName": "[concat('nhsukfeedback', parameters('environment'), variables('locationAbbreviation'))]",
"hostingPlanName": "[concat('nhsuk-user-feedback-plan-', parameters('environment'), '-', variables('locationAbbreviation'))]",
"appInsightsName": "[parameters('functionAppName')]",
"databaseName": "[concat('nhsuk-user-feedback-db-', parameters('environment'))]",
"tags": {
"Owner": "[parameters('ownerTag')]",
"Product": "User Feedback",
"Build": "[parameters('buildTag')]",
"Expires": "[parameters('expiresTag')]",
"Environment": "[parameters('environment')]"
}
},
"resources": [
{
"type": "Microsoft.Web/sites",
"apiVersion": "2019-08-01",
"name": "[parameters('functionAppName')]",
"kind": "functionapp,linux",
"location": "[parameters('location')]",
"dependsOn": [
"[concat('microsoft.insights/components/', variables('appInsightsName'))]",
"[concat('Microsoft.Web/serverfarms/', variables('hostingPlanName'))]",
"[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
"[concat('Microsoft.DocumentDB/databaseAccounts/', variables('databaseName'))]"
],
"tags": "[variables('tags')]",
"properties": {
"name": "[parameters('functionAppName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"siteConfig": {
"appSettings": [
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~3"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "node"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(concat('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').InstrumentationKey]"
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[reference(concat('microsoft.insights/components/', variables('appInsightsName')), '2015-05-01').ConnectionString]"
},
{
"name": "WEBSITE_NODE_DEFAULT_VERSION",
"value": "~12"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';EndpointSuffix=','core.windows.net')]"
},
{
"name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';EndpointSuffix=','core.windows.net')]"
},
{
"name": "WEBSITE_CONTENTSHARE",
"value": "[toLower(parameters('functionAppName'))]"
},
{
"name": "MONGO_CONNECTION_STRING",
"value": "[concat(listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', variables('databaseName')), '2019-12-12').connectionStrings[0].connectionString, '&retrywrites=false&maxIdleTimeMS=120000')]"
}
],
"cors": {
"allowedOrigins": [
"[if(parameters('enableCORS'), '*', 'https://www.nhs.uk')]"
]
}
},
"reserved": true
}
},
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2019-06-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"sku": {
"name": "Standard_LRS"
},
"properties": {
"supportsHttpsTrafficOnly": true
}
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2019-08-01",
"name": "[variables('hostingPlanName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"sku": {
"Tier": "[parameters('hostingPlanSkuTier')]",
"Name": "[parameters('hostingPlanSkuName')]"
},
"kind": "linux",
"properties": {
"reserved": true
}
},
{
"type": "microsoft.insights/components",
"apiVersion": "2015-05-01",
"name": "[variables('appInsightsName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"kind": "web",
"properties": {
"Request_Source": "rest",
"Application_Type": "web"
}
},
{
"type": "Microsoft.DocumentDB/databaseAccounts",
"apiVersion": "2020-03-01",
"name": "[variables('databaseName')]",
"location": "[parameters('location')]",
"tags": "[variables('tags')]",
"kind": "MongoDB",
"properties": {
"locations": [{
"locationName": "[parameters('location')]"
}],
"databaseAccountOfferType": "Standard",
"capabilities": [
{
"name": "EnableMongo"
}
]
}
}
],
"outputs": {
"functionAppName": {
"type": "string",
"value": "[parameters('functionAppName')]"
},
"storageAccountName": {
"type": "string",
"value": "[variables('storageAccountName')]"
}
}
}
56 changes: 56 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# Run pipeline on master branch, pull-requests into master, and tags
trigger:
branches:
include:
- master
- refs/tags/*
pr:
- master


pool:
vmImage: 'ubuntu-latest'

stages:
- stage: Test
jobs:
- job: Test

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'

- script: |
npm install
npm test
displayName: 'npm test'
- stage: Build
displayName: Build stage
jobs:
- job: Build

steps:
- task: NodeTool@0
inputs:
versionSpec: '10.x'
displayName: 'Install Node.js'

- script: |
npm install --production
displayName: 'npm install'
- task: ArchiveFiles@2
displayName: 'Archive files'
inputs:
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
includeRootFolder: false
archiveType: zip
archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
replaceExistingArchive: true

- upload: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
artifact: drop

0 comments on commit 2171a4c

Please sign in to comment.