Skip to content

Instantly share code, notes, and snippets.

@appcoreopc
Created August 2, 2021 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save appcoreopc/db4ad535114af5781265b992ae75cb18 to your computer and use it in GitHub Desktop.
Save appcoreopc/db4ad535114af5781265b992ae75cb18 to your computer and use it in GitHub Desktop.
hostBindingsDev: '{"bindings":[{"protocol":"http","ipAddress":"All Unassigned","port":"80","hostname":"payments-dev","sslThumbprint":"","sniFlag":false}]}'
parameters:
stageDependency: []
stageName: ''
env: ''
targetServerGroup: ''
packageName: ''
targetWebsiteName: ''
installationPath: ''
targetport: ''
targetWebsiteAppPool: ''
targetWebsiteDirectory: ''
artifactFeed: ''
artifactPackage: ''
variableGroup: ''
isAPI: false
deploymentWebApplicationName: ''
packageVersion : ''
alwaysDeploy: false
hostBindings: ''
stages:
- stage : ${{parameters.stageName}}
dependsOn: ${{parameters.stageDependency}}
condition: and(succeeded(), or(eq(variables.isMasterOrReleasableBranch, true), eq(${{ parameters.alwaysDeploy}}, true)))
variables:
- group: ${{parameters.variableGroup}}
jobs:
- deployment: ${{parameters.stageName}}
displayName: ${{parameters.stageName}}
pool:
vmImage: 'windows-latest'
environment:
name: ${{parameters.targetServerGroup}}
resourceType: VirtualMachine
strategy:
runOnce:
deploy:
steps:
- checkout: self
- task: DownloadPackage@1
inputs:
packageType: 'nuget'
feed: ${{parameters.artifactFeed}}
definition: ${{parameters.artifactPackage}}
version: ${{parameters.packageVersion}}
extract: false
downloadPath: '$(System.ArtifactsDirectory)'
- task: PowerShell@2
displayName: 'Rename nupkg file to zip file'
inputs:
targetType: 'inline'
script: |
Move-Item $(System.ArtifactsDirectory)/*.nupkg $(System.ArtifactsDirectory)/${{parameters.packageName}}.zip -force
- task: PowerShell@2
displayName: 'Output variable bindings info for monitoring purposes.'
inputs:
targetType: 'inline'
script: |
Write-Host("parameters.hostBindings value")
Write-Host '${{parameters.hostBindings}}'
- task: FileTransform@1
condition: eq('${{ parameters.isAPI }}', true)
inputs:
folderPath: '$(System.ArtifactsDirectory)/${{parameters.packageName}}.zip'
enableXmlTransform: true
fileType: 'json'
targetFiles: 'appsettings.json'
- task: IISWebAppManagementOnMachineGroup@0
displayName: 'Manage PaymentManager.Client IISWebsite'
condition: eq('${{ parameters.isAPI }}', false)
inputs:
WebsiteName: ${{parameters.targetWebsiteName}}
WebsitePhysicalPath: ${{parameters.installationPath}}
AddBinding: true
Bindings: ${{parameters.hostBindings}}
CreateOrUpdateAppPoolForWebsite: true
AppPoolNameForWebsite: ${{parameters.targetWebsiteAppPool}}
AppPoolIdentityForWebsite: ApplicationPoolIdentity
ParentWebsiteNameForApplication: ${{parameters.targetWebsiteName}}
VirtualPathForApplication: ${{parameters.targetWebsiteDirectory}}
PhysicalPathForApplication: ${{parameters.installationPath}}
CreateOrUpdateAppPoolForApplication: true
AppPoolNameForApplication: ${{parameters.targetWebsiteAppPool}}
AppCmdCommands: 'set config /section:anonymousAuthentication /enabled:true'
- task: IISWebAppManagementOnMachineGroup@0
displayName: 'Manage PaymentManager.API IISWebApplication'
condition: eq('${{ parameters.isAPI }}', true)
inputs:
IISDeploymentType: 'IISWebApplication'
ParentWebsiteNameForApplication: ${{parameters.targetWebsiteName}}
VirtualPathForApplication: ${{parameters.targetWebsiteDirectory}}
PhysicalPathForApplication: ${{parameters.installationPath}}
CreateOrUpdateAppPoolForApplication: true
AppPoolNameForApplication: ${{parameters.targetWebsiteAppPool}}
AppCmdCommands: 'set config /section:windowsAuthentication /enabled:true'
- task: IISWebAppDeploymentOnMachineGroup@0
displayName: 'Deploy IIS Website/App: '
inputs:
WebSiteName: ${{parameters.deploymentWebApplicationName}}
Package: '$(System.ArtifactsDirectory)/${{parameters.packageName}}.zip'
TakeAppOfflineFlag: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment