mirror of
https://dev.azure.com/effectory/Survey%20Software/_git/Cloud%20Engineering
synced 2026-02-27 18:52:18 +01:00
Added front door routes and sql stats queries
This commit is contained in:
77
Powershell/Lists/Azure/FrontDoorRoutes.ps1
Normal file
77
Powershell/Lists/Azure/FrontDoorRoutes.ps1
Normal file
@@ -0,0 +1,77 @@
|
||||
# .\FrontDoorRoutes.ps1 -SubscriptionId "4820b5d8-cc1d-49bd-93e5-0c7a656371b7" -ResourceGroupName "my-effectory-global" -FrontDoorName "my-effectory-frontDoor"
|
||||
|
||||
param(
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]$SubscriptionId,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$ResourceGroupName,
|
||||
|
||||
[Parameter(Mandatory=$true)]
|
||||
[string]$FrontDoorName
|
||||
)
|
||||
|
||||
[string] $date = Get-Date -Format "yyyy-MM-dd HHmm"
|
||||
$fileName = ".\$date Front Door Routes ($FrontDoorName).csv"
|
||||
|
||||
# Connect to Azure if not already connected
|
||||
if (-not (Get-AzContext)) {
|
||||
Connect-AzAccount
|
||||
}
|
||||
|
||||
# Select subscription if provided
|
||||
if ($SubscriptionId) {
|
||||
Select-AzSubscription -SubscriptionId $SubscriptionId
|
||||
Write-Host "Selected subscription: $SubscriptionId" -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
try {
|
||||
# Get Front Door profile
|
||||
$frontDoor = Get-AzFrontDoorCdnProfile -ResourceGroupName $ResourceGroupName -Name $FrontDoorName
|
||||
|
||||
if (-not $frontDoor) {
|
||||
Write-Error "Front Door '$FrontDoorName' not found in resource group '$ResourceGroupName'"
|
||||
return
|
||||
}
|
||||
|
||||
# Get all endpoints
|
||||
$endpoints = Get-AzFrontDoorCdnEndpoint -ResourceGroupName $ResourceGroupName -ProfileName $FrontDoorName
|
||||
|
||||
$routeData = @()
|
||||
|
||||
foreach ($endpoint in $endpoints) {
|
||||
# Get routes for each endpoint
|
||||
$routes = Get-AzFrontDoorCdnRoute -ResourceGroupName $ResourceGroupName -ProfileName $FrontDoorName -EndpointName $endpoint.Name
|
||||
|
||||
foreach ($route in $routes) {
|
||||
# Get origin group details
|
||||
$originGroupId = $route.OriginGroupId
|
||||
$originGroupName = ($originGroupId -split '/')[-1]
|
||||
|
||||
$origins = Get-AzFrontDoorCdnOrigin -ResourceGroupName $ResourceGroupName -ProfileName $FrontDoorName -OriginGroupName $originGroupName
|
||||
|
||||
foreach ($origin in $origins) {
|
||||
$routeData += [PSCustomObject]@{
|
||||
FrontDoorName = $FrontDoorName
|
||||
EndpointName = $endpoint.Name
|
||||
RouteName = $route.Name
|
||||
RoutePatterns = ($route.PatternsToMatch -join '; ')
|
||||
RouteUrl = "https://$($endpoint.HostName)"
|
||||
OriginGroupName = $originGroupName
|
||||
OriginName = $origin.Name
|
||||
OriginUrl = $origin.HostName
|
||||
OriginEnabled = $origin.EnabledState
|
||||
RouteEnabled = $route.EnabledState
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Export to CSV
|
||||
Write-Host "Exporting Front Door routes to: $fileName" -ForegroundColor Green
|
||||
$routeData | Export-Csv -Path $fileName -NoTypeInformation -Force
|
||||
|
||||
|
||||
} catch {
|
||||
Write-Error "Error retrieving Front Door routes: $($_.Exception.Message)"
|
||||
}
|
||||
Reference in New Issue
Block a user