Last active
May 23, 2021 05:22
-
-
Save Ba4bes/618392bf20a02727d625cebdc20b5563 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Starter pipeline | |
# Start with a minimal pipeline that you can customize to build and deploy your code. | |
# Add steps that build, run tests, deploy, and more: | |
# https://aka.ms/yaml | |
trigger: | |
- "*" | |
stages: | |
- stage: test | |
jobs: | |
- job: 'validateandtest' | |
pool: | |
vmimage: windows-latest | |
steps: | |
- task: AzureResourceManagerTemplateDeployment@3 | |
displayName: "Validate Template" | |
inputs: | |
deploymentScope: 'Resource Group' | |
azureResourceManagerConnection: 'AzureConnection' | |
subscriptionId: '[subscriptionID here]' | |
action: 'Create Or Update Resource Group' | |
resourceGroupName: 'ARMDeploymentTest' | |
location: 'West Europe' | |
templateLocation: 'Linked artifact' | |
csmFile: '$(Build.SourcesDirectory)/StorageAccount/azuredeploy.json' | |
csmParametersFile: '$(Build.SourcesDirectory)/StorageAccount/azuredeploy.parameters.json' | |
deploymentMode: 'Validation' | |
- task: PowerShell@2 | |
inputs: | |
targetType: 'inline' | |
script: | | |
Install-Module Az.Resources -RequiredVersion 1.12.1-preview -AllowPrerelease -Force -Scope CurrentUser | |
- task: AzurePowerShell@5 | |
displayName: "Show deployed Resources" | |
inputs: | |
azureSubscription: 'AzureConnection' | |
ScriptType: 'InlineScript' | |
Inline: | | |
$Parameters = @{ | |
ResourcegroupName = "ARMDeploymentTest" | |
Templatefile = ".\StorageAccount\azuredeploy.json" | |
TemplateParameterfile = ".\StorageAccount\azuredeploy.parameters.json" | |
Mode = 'Incremental' | |
} | |
$Result = Get-AzResourceGroupDeploymentWhatIfResult @Parameters | |
$Result | |
azurePowerShellVersion: 'LatestVersion' | |
- task: AzurePowerShell@5 | |
displayName: "Check for deletion" | |
inputs: | |
azureSubscription: 'AzureConnection' | |
ScriptType: 'FilePath' | |
ScriptPath: '$(Build.SourcesDirectory)/Tests/CheckForDeletion.ps1' | |
ScriptArguments: '-ResourceGroup ARMDeploymentTest' | |
FailOnStandardError: true | |
azurePowerShellVersion: 'LatestVersion' | |
- stage: Deploy | |
condition: | |
and( | |
succeeded(), | |
eq(variables['Build.SourceBranch'], 'refs/heads/master') | |
) | |
dependsOn: | |
test | |
jobs: | |
- job: "deployARM" | |
pool: | |
vmimage: windows-latest | |
steps: | |
- task: AzureResourceManagerTemplateDeployment@3 | |
inputs: | |
deploymentScope: 'Resource Group' | |
azureResourceManagerConnection: 'AzureConnection' | |
subscriptionId: '[subscriptionID here]' | |
action: 'Create Or Update Resource Group' | |
resourceGroupName: 'ARMDeploymentTest' | |
location: 'West Europe' | |
templateLocation: 'Linked artifact' | |
csmFile: '$(Build.SourcesDirectory)/StorageAccount/azuredeploy.json' | |
csmParametersFile: '$(Build.SourcesDirectory)/StorageAccount/azuredeploy.parameters.json' | |
deploymentMode: 'Incremental' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment