Virtual Machine Daily Availability Requirement | Automated Start Stop Solution Implemented | Hours Saved | Number of Hours Running/Month | Monthly Total Hours Billed | Savings |
---|---|---|---|---|---|
Always Running - 24 Hours | None | 0 | 720 | 720 | 0 |
Only Needed During WeekDays - 24 hours | Stop on Friday UTC 08:00 and Start on Monday UTC 22:00 | 248 | 472 | 472 | %34.5 |
Only Needed During Weekdays for 10 hours | Monday to Friday --> Start at UTC 22:00 , Stop at UTC 08:00 | 472 | 248 | 248 | %65.5 |
View Deploy-AzARMTemplate-with-loop-example.ps1
This file contains 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
#region Service Constants | |
$ProjectName = 'mert' | |
$Stage = 'dev' | |
$ServiceType = 'fnc' | |
#$Region = "wus" | |
$Regions = "wus", "aue" ,"neu" | |
foreach($Region in $Regions) { | |
# The rest of the Deployment code logic goes here. | |
} |
View Deploy-AzARMTemplate-with-secret-example.ps1
This file contains 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
param ( | |
[Parameter()][switch]$WhatIf, | |
[Parameter()][switch]$Test, | |
[Parameter()][switch]$Force, | |
[Parameter()][securestring]$mySecretValue | |
) | |
$ARGS = @{ | |
ResourceGroupName = $ResourceGroupName | |
TemplateFile = $TemplateFile |
View Deploy-AzARMTemplate-region5.ps1
This file contains 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
#region Deployment ("Validate & Deploy" or "Forced" Deployment) | |
try { | |
$PromptForConfirmation = (($Force) ? $false : $true) | |
Write-Host "Deploying $Region" | |
$Deployment = New-AzResourceGroupDeployment @ARGS ` | |
-Name "$(New-Guid)" ` | |
-Confirm:$PromptForConfirmation ` | |
-WhatIfResultFormat FullResourcePayloads | |
} | |
catch { |
View Deploy-AzARMTemplate-region4.ps1
This file contains 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
#region Deployment Helpers | |
$ErrorActionPreference = "Stop" | |
if ($Test) { | |
Test-AzResourceGroupDeployment @ARGS | |
exit $LASTEXITCODE | |
} | |
if ($WhatIf) { | |
$WhatIfResult = Get-AzResourceGroupDeploymentWhatIfResult @ARGS ` | |
-ResultFormat FullResourcePayloads | |
$WhatIfResult |
View Deploy-AzARMTemplate-region3.ps1
This file contains 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
#region Service Constants | |
$ProjectName = 'mert' | |
$Stage = 'dev' | |
$ServiceType = 'fnc' | |
$Region = "wus" | |
#endregion | |
#region Service Curated Parameters | |
$ResourceGroupName = $ProjectName + $Stage + $ServiceType + $Region + '01' | |
$TemplateFile = "$ArmArtifactsPath\template.json" |
View Deploy-AzARMTemplate-region2.ps1
This file contains 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
#region Connect to Correct Tenant and Subscription | |
$CurrentContext = Get-AzContext | |
#If there is no AzContext found connect to desired Subscription and Tenant | |
if (!$CurrentContext) { | |
Connect-AzAccount -Tenant $TenantId -Subscription $SubscriptionId -UseDeviceAuthentication | |
$CurrentContext = Get-AzContext | |
} | |
#If subscription ID doesnt match, call the Set-AzContext with | |
#SubscriptionId and TenantId to allow switch between tenants as well. | |
if ($CurrentContext.Subscription.Id -ne $SubscriptionId) { |
View Deploy-AzARMTemplate-region1.ps1
This file contains 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
#Requires -Module @{ ModuleName = 'Az'; ModuleVersion = '4.2' } | |
[CmdletBinding()] | |
param ( | |
[Parameter()][switch]$WhatIf, | |
[Parameter()][switch]$Test, | |
[Parameter()][switch]$Force | |
) | |
#region Configuration | |
#Deployment Assets Configuration |
View Deploy-AzARMTemplate.ps1
This file contains 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
<# | |
.DESCRIPTION | |
Tests, Validates or Deploys Azure Resource Manager Template | |
.PARAMETER Test | |
Switch for only running the Offline Template Validation | |
.PARAMETER WhatIf | |
Switch for only running the What-If Validation, that simulates a deployment via the Azure ARM REST API |
View sample-savings-vm-auto-start-stop.md
View sample-az-sub-structure.md
Subscription No | Subscription Name |
---|---|
1 | IT Operations |
2 | Project 1 - Development |
3 | Project 1 - Test |
4 | Project 1- Staging |
5 | Project 1 - Production |
6 | Project 2 - Development |
7 | .... |
8 | .... |
NewerOlder