-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCollectAzFuncDashboardLogging.ps1
45 lines (41 loc) · 2.28 KB
/
CollectAzFuncDashboardLogging.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
$subscriptionName = "<SubscriptionName>" #Provide the subscription name
##Install and Import required Modules. Run in administrator mode to install it
##Uninstall AzureRM module , Az and AzureRm cannot be installed together. Run Uninstall-AzureRm command
If (!( Get-Module | Where-Object { $_.Name -eq "Az" })) {
Install-Module "Az" -Force
}
Import-Module "Az" -Force
# #Connect to Azure account
Connect-AzAccount -Subscription $subscriptionName
#Gather Data
$output = New-Object System.Collections.Generic.List[Object]
#Uncomment below line and comment the next to neqxt line if you want to filter by resoruce group.
#Get-AzFunctionapp -ResourceGroupName "<<ResourceGroupname>>" | ForEach-Object {
Get-AzFunctionapp | ForEach-Object {
$awjd = (Get-AzFunctionAppSetting -Name $_.Name -ResourceGroupName $_.ResourceGroupName)["AzureWebJobsDashboard"]
if ($awjd) {
$webJobsDashboardConfigured = $true
}
else {
$awjd = (Get-AzFunctionAppSetting -Name $_.Name -ResourceGroupName $_.ResourceGroupName)["AzureWebJobsStorage"]
$webJobsDashboardConfigured = $false
}
$storageAccountName = (($awjd -split ";")[1] -split "=")[1]
$getStorageAccountDetails = Get-AzStorageAccount -ResourceGroupName $_.ResourceGroupName -AccountName $storageAccountName
$tableCount = ($getStorageAccountDetails | Get-AzStorageTable).count
$saId = ($getStorageAccountDetails).id
$storageAccountAvgSizeMB = (Get-AzMetric -ResourceId $saId -MetricName "UsedCapacity" -AggregationType Average).Data.Average / 1024 / 1024
$tableServiceAvgSizeMB = (Get-AzMetric -ResourceId "$saId/tableServices/default" -MetricName "TableCapacity" -AggregationType Average).Data.Average / 1024 / 1024
$outObject = [PSCustomObject]@{
FunctionAppName = $_.Name
ResourceGroupName = $_.ResourceGroupName
AzureWebJobsDashboardConfigured = $webJobsDashboardConfigured
StorageAccountName = $storageAccountName
StorageAccountAvgSizeinMB = $storageAccountAvgSizeMB.tostring("#.##")
TableServiceAvgSizeinMB = $tableServiceAvgSizeMB.tostring("#.##")
TotalTables = $tableCount
}
$output.Add($outObject)
}
Write-Output $output
$output | Export-Csv -Path "./export.csv"