Output of this Packer template is Hyper-V Gen2 VM with Debian 10 that supports direct connection via vsock
thus no internet connectivity is needed.
$key = "$env:USERPROFILE\.ssh\lab01_rsa"
$publicKey = Get-Content "$($key).pub"| locals { | |
| ike_secret = "tajneheslo" | |
| # Azure site | |
| ip_azure_range = "10.10.0.0/16" | |
| ip_azure_subnet_main = "10.10.0.0/24" | |
| ip_azure_subnet_gw = "10.10.255.240/28" | |
| asn_azure = "65010" | |
| # On-premises site |
| function Invoke-AzVMDiskSnapshot { | |
| param( | |
| [Parameter(Mandatory = $true)] | |
| [string]$VMResourceGroupName, | |
| [Parameter(Mandatory = $true)] | |
| [string]$VMName, | |
| [string]$SnapshotsResourceGroupName = $null | |
| [bool]$Shutdown = $true | |
| ) |
To set how far in the future (in months) to prepare deployment rings set variable $monthsToProvision
To set deployment rings populate tags to $deploymentRings hash table in format
<TagName> = <Time-Span for delayed deployment>
Make sure that in addition to Az PowerShell module you also have Az.PrivateDns module installed.
Function Sync-DnsZone synchronizes resource records from source DNS zone to destination DNS zone, if you want to achive two-way sync you need to execute the same function twice with switched source and destination.
| #region Functions | |
| function ConvertFrom-Timestamp { | |
| param( | |
| [Parameter(Mandatory = $true)] | |
| [int]$Timestamp | |
| ) | |
| $utc = (Get-Date 01.01.1970) + ([System.TimeSpan]::fromseconds($Timestamp)) | |
| $datetime = [datetime]::SpecifyKind($utc, 'Utc').ToLocalTime() |
| #region Azure Automation bootstrap | |
| try | |
| { | |
| $servicePrincipalConnection = Get-AutomationConnection -Name "AzureRunAsConnection" | |
| "Logging in to Azure..." | |
| Connect-AzAccount ` | |
| -ServicePrincipal ` | |
| -TenantId $servicePrincipalConnection.TenantId ` | |
| -ApplicationId $servicePrincipalConnection.ApplicationId ` | |
| -CertificateThumbprint $servicePrincipalConnection.CertificateThumbprint |
| Param( | |
| [Parameter (Mandatory = $true)] | |
| [sring]$DnsName, | |
| [string]$RouteName | |
| ) | |
| if($RouteName -eq "") { | |
| $RouteName = $DnsName | |
| } |