Skip to content
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

Added azure-pipelines, GitHub workflow and SampleApp.yaml #6

Merged
merged 43 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
47727a9
Merge pull request #1 from nikitanallamothu/users/nijoy/secrets_impl
ninallam Nov 21, 2021
5ee682b
Create main.yml
ninallam Nov 21, 2021
2ca0ae4
Create azure-pipelines.yml
ninallam Nov 21, 2021
ef3b578
Update main.yml
ninallam Nov 21, 2021
fe6554c
Update windows-webapp-template.json
ninallam Nov 21, 2021
d6cdc8a
Set up CI with Azure Pipelines
ninallam Nov 21, 2021
e3706b0
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
f7f96d1
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
c116016
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
f487723
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
ce1f7fd
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
7facd85
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
a3f7ffd
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
d78ea01
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
d4a8ac6
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
45ad653
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
d75e18b
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
649cfb5
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
e73f5b9
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
8c08242
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
a30f33f
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
f23cb7a
Update main.yml
ninallam Nov 21, 2021
5438824
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
03af059
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 21, 2021
68b69d5
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
6707e11
Update main.yml
ninallam Nov 22, 2021
dd92da4
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
eae63f5
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
999d62d
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
85b10a5
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
60b584c
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
cabbdda
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
ca1e0b5
Update azure-pipelines.yml for Azure Pipelines
ninallam Nov 22, 2021
c369fab
Update main.yml
ninallam Nov 22, 2021
6fb5180
Update main.yml
ninallam Nov 22, 2021
85b4f3d
Update config.json
ninallam Nov 22, 2021
254e8bc
Update config.json
ninallam Nov 22, 2021
560ada5
Update config.json
ninallam Nov 22, 2021
3c06dd5
Add files via upload
ninallam Nov 22, 2021
e35f2ad
Update azure-pipelines.yml
ninallam Nov 22, 2021
6c670d1
Update and rename main.yml to workflow.yml
ninallam Nov 22, 2021
922a099
Update config.json
ninallam Nov 22, 2021
6f84e48
Update windows-webapp-template.json
ninallam Nov 22, 2021
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
94 changes: 94 additions & 0 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# This is a basic workflow to help you get started with Actions

name: Sample App deploy

# Controls when the workflow will run
on:
workflow_dispatch:

env:
AZURE_WEBAPP_NAME: "<Name of your webapp>" # set this to your application's name
LOAD_TEST_RESOURCE: "<Name of your load test resource>"
LOAD_TEST_RESOURCE_GROUP: "<Name of your load test resource group>"
AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
NODE_VERSION: '14.15.1' # set this to the node version to use
LOCATION: "West US"
APPINSIGHTLOCATION: "West US"
DATABASEACCOUNTLOCATION: "westus"

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build-and-deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout GitHub Actions
uses: actions/checkout@v2

- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}

- name: npm install and build
continue-on-error: false
run: |
npm install
npm run build --if-present
npm run test --if-present

- name: Login to Azure
uses: azure/login@v1
continue-on-error: false
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

# Deploy Arm template
- name: Deploy ARM Template
uses: azure/powershell@v1
continue-on-error: false
with:
inlineScript: |
az group create --name "${{ env.AZURE_WEBAPP_NAME }}-rg" --location "${{ env.LOCATION }}"
$deploymentOutputs = az deployment group create --resource-group "${{ env.AZURE_WEBAPP_NAME }}-rg" --mode Incremental --template-file ./windows-webapp-template.json --parameters webAppName="${{ env.AZURE_WEBAPP_NAME }}" --parameters hostingPlanName="${{ env.AZURE_WEBAPP_NAME }}-host" --parameters appInsightsLocation="${{ env.APPINSIGHTLOCATION }}" --parameters databaseAccountId="${{ env.AZURE_WEBAPP_NAME }}db" --parameters databaseAccountLocation="${{ env.DATABASEACCOUNTLOCATION }}" -o json
$deploymentOutputs = $deploymentOutputs | ConvertFrom-Json
$connectionString = [String]$deploymentOutputs.properties.outputs.azureCosmosDBAccountKeys.value
$setConnectionString = az webapp config appsettings set --name "${{ env.AZURE_WEBAPP_NAME }}" --resource-group "${{ env.AZURE_WEBAPP_NAME }}-rg" --settings CONNECTION_STRING="$connectionString"
$setAppSettings = az webapp config appsettings set --name "${{ env.AZURE_WEBAPP_NAME }}" --resource-group "${{ env.AZURE_WEBAPP_NAME }}-rg" --settings MSDEPLOY_RENAME_LOCKED_FILES=1
$setAppSettings = az webapp config appsettings set --name "${{ env.AZURE_WEBAPP_NAME }}" --resource-group "${{ env.AZURE_WEBAPP_NAME }}-rg" --settings SCM_DO_BUILD_DURING_DEPLOYMENT=true
azPSVersion: "latest"

- name: 'Deploy to Azure WebApp'
uses: azure/webapps-deploy@v2
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

loadTest:
name: Load Test
needs: build-and-deploy
runs-on: ubuntu-latest
steps:
- name: Checkout GitHub Actions
uses: actions/checkout@v2

- name: Login to Azure
uses: azure/login@v1
continue-on-error: false
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}

- name: 'Azure Load Testing'
uses: azure/load-testing@v1
with:
loadTestConfigFile: 'SampleApp.yaml'
loadTestResource: ${{ env.LOAD_TEST_RESOURCE }}
resourceGroup: ${{ env.LOAD_TEST_RESOURCE_GROUP }}

- uses: actions/upload-artifact@v2
with:
name: loadTestResults
path: ${{ github.workspace }}/loadTest
5 changes: 5 additions & 0 deletions SampleApp.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
version: v0.1
testName: SampleAppTest
testPlan: SampleApp.jmx
description: 'SampleApp Test Run'
engineInstances: 1
155 changes: 155 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Node.js
# Build a general Node.js project with npm.
# Add steps that analyze code, save build artifacts, deploy, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/javascript

trigger:
- main

pool:
vmImage: ubuntu-latest

variables:
webAppName: '<Name of your webapp>'
serviceConnection: '<Name of your webARM Service connection>'
azureSubscriptionId: '<Azure subscriptionId>'
loadTestResource: '<Name of your load test resource>'
loadTestResourceGroup: '<Name of your load test resource group>'
location: 'EAST US'


stages:
- stage: Build
displayName: Build
jobs:
- job: Build
displayName: Build
pool:
vmImage: windows-latest

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

- script: |
npm install
npm run build
displayName: 'npm install and build'

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

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

- stage: Deploy
displayName: Deploy
dependsOn: Build
condition: succeeded()
jobs:
- job: Deploy
displayName: Deploy
pool:
vmImage: windows-latest

steps:
- task: AzureResourceManagerTemplateDeployment@3
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: $(serviceConnection)
subscriptionId: $(azureSubscriptionId)
action: 'Create Or Update Resource Group'
resourceGroupName: '$(webAppName)-rg'
location: 'East US'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/windows-webapp-template.json'
overrideParameters: '-webAppName $(webAppName) -hostingPlanName $(webAppName)-host -appInsightsLocation "East US" -databaseAccountId $(webAppName)db -databaseAccountLocation "East US"'
deploymentMode: 'Incremental'
deploymentOutputs: 'output'

- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
$deploymentOutput= ConvertFrom-Json '$(output)'
$connectionStringValue= $deploymentOutput.azureCosmosDBAccountKeys.value
Write-Host "##vso[task.setvariable variable=connectionString;issecret=true;]$connectionStringValue"

- task: AzureAppServiceSettings@1
inputs:
azureSubscription: $(serviceConnection)
appName: '$(webAppName)'
resourceGroupName: '$(webAppName)-rg'
appSettings: |
[
{
"name": "CONNECTION_STRING",
"value": "$(connectionString)",
"slotSetting": false
},
{
"name": "MSDEPLOY_RENAME_LOCKED_FILES",
"value": 1,
"slotSetting": false
},
{
"name": "SCM_DO_BUILD_DURING_DEPLOYMENT",
"value": true,
"slotSetting": false
}
]

- task: DownloadPipelineArtifact@2
inputs:
artifact: drop

- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(serviceConnection)
appType: 'webApp'
WebAppName: $(webAppName)
packageForLinux: '$(Pipeline.Workspace)/$(Build.BuildId).zip'
ScriptType: 'Inline Script'
InlineScript: 'npm install'
- task: DownloadPipelineArtifact@2
inputs:
artifact: drop
- task: AzureRmWebAppDeployment@4
inputs:
ConnectionType: 'AzureRM'
azureSubscription: $(serviceConnection)
appType: 'webApp'
WebAppName: $(webAppName)
packageForLinux: '$(Pipeline.Workspace)/$(Build.BuildId).zip'
enableCustomDeployment: true
DeploymentType: 'zipDeploy'
TakeAppOfflineFlag: false

- stage: LoadTest
displayName: Load Test
dependsOn: Deploy
condition: succeeded()
jobs:
- job: LoadTest
displayName: Load Test
pool:
vmImage: ubuntu-latest
steps:
- task: AzureLoadTest@1
inputs:
azureSubscription: $(serviceConnection)
loadTestConfigFile: 'SampleApp.yaml'
resourceGroup: $(loadTestResourceGroup)
loadTestResource: $(loadTestResource)

- publish: $(System.DefaultWorkingDirectory)/loadTest
artifact: results
2 changes: 1 addition & 1 deletion config.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"enableSecretsFeature": false,
"secretHeaderValue": "1797669089"
}
}
2 changes: 1 addition & 1 deletion windows-webapp-template.json
Original file line number Diff line number Diff line change
Expand Up @@ -166,4 +166,4 @@
"type": "string"
}
}
}
}