mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 18:52:18 +01:00
38 lines
1.5 KiB
PowerShell
38 lines
1.5 KiB
PowerShell
function Set-BlobEffectoryDomainResources {
|
|
<#
|
|
.SYNOPSIS
|
|
Stores the effectory domain resources list as csv in Azure storage.
|
|
.DESCRIPTION
|
|
Stores the effectory domain resources list as csv in Azure storage, while making a backup of the previous state.
|
|
.PARAMETER effectoryResources
|
|
Resources to be exported to CSV.
|
|
.PARAMETER connectionString
|
|
Connection string of the storage account to save to.
|
|
#>
|
|
|
|
param(
|
|
[Parameter(Mandatory)]
|
|
[EffectoryDomainNameCheck[]] $effectoryResources,
|
|
[Parameter(Mandatory)]
|
|
[string] $connectionString
|
|
)
|
|
|
|
[string] $fileName = "$((Get-Date).ToString("yyyy-MM-dd HH-mm-ss")) - resources.csv"
|
|
Write-Verbose "Storing resources to $($fileName)"
|
|
|
|
$context = New-AzStorageContext -ConnectionString $connectionString
|
|
|
|
# move to history
|
|
$blobs = Get-AzStorageBlob -Container "dangling-dns" -Context $context
|
|
if ($null -ne $blobs) {
|
|
foreach ($blob in $blobs) {
|
|
Start-AzStorageBlobCopy -CloudBlob $blob.ICloudBlob -DestContainer "dangling-dns-history" -DestBlob $blob.Name -Context $context -Force >$null
|
|
Remove-AzStorageBlob -Container "dangling-dns" -Blob $blob.Name -Context $context -Force >$null
|
|
}
|
|
}
|
|
|
|
# store as current
|
|
$effectoryResources | Export-Csv "$Env:temp/$($fileName)"
|
|
Set-AzStorageBlobContent -Context $context -Container "dangling-dns" -File "$Env:temp/$($fileName)" -Blob $fileName -Force >$null
|
|
Remove-Item -Path "$Env:temp/$($fileName)"
|
|
} |