Skip to content

Instantly share code, notes, and snippets.

@ivanbuzyka
Last active September 2, 2019 09:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanbuzyka/a282b58da91f5388b77f39bb1e53d49a to your computer and use it in GitHub Desktop.
Save ivanbuzyka/a282b58da91f5388b77f39bb1e53d49a to your computer and use it in GitHub Desktop.
Collect basic Sitecore Azure PaaS setup information for web apps, hosting plans, Azure SQL DBs, Redis Cache and Azure Search. [ProjectReview]
### PREREQUISITES
### In order to run this script you need to install new Az PowerShell module including Az.Search module
################# Functions
function Get-WebAppsBasicInfo {
param (
[string]$ResourceGroupName,
[string]$OutputCsvFilePath
)
$hostingPlansResources = Get-AzResource -ResourceType "Microsoft.Web/serverfarms" -ResourceGroupName $ResourceGroupName
$hps = @()
foreach ($res in $hostingPlansResources) {
$temp = Get-AzAppServicePlan -Name $res.Name -ResourceGroupName $ResourceGroupName
$tempWebApps = Get-AzWebApp -AppServicePlan $temp
$webapps = [string]::Join("|", $tempWebApps.Name)
$hps += [PSCustomObject]@{
HostingPlanName = $temp.Name
NumberOfSites = $temp.NumberOfSites
Size = $temp.Sku.Name
InstancesCount = $temp.Sku.Capacity
WebApps = $webapps
}
}
$hps | Select-Object -Property HostingPlanName, NumberOfSites, Size, InstancesCount, WebApps | Export-Csv -Path $OutputCsvFilePath -Delimiter ';'
}
function Get-SqlBasicInfo {
param (
[string]$ResourceGroupName,
[string]$OutputCsvFolderPath
)
$sqlServers = Get-AzSqlServer -ResourceGroupName $ResourceGroupName
$dbs = @()
foreach ($server in $sqlServers) {
$tempDbs = Get-AzSqlDatabase -ServerName $server.ServerName -ResourceGroupName $ResourceGroupName
$tempDbs | Select-Object -Property DatabaseName, ServerName, CurrentServiceObjectiveName, SkuName, Capacity, Location, ElasticPoolName | Export-Csv -Path ($OutputCsvFolderPath + "\" + $server.ServerName + ".csv") -Delimiter ';'
}
}
function Get-AzureSearchBasicInfo {
param (
[string]$ResourceGroupName,
[string]$OutputCsvFilePath
)
$searchService = Get-AzSearchService -ResourceGroupName $ResourceGroupName
$searchService | Select-Object -Property Name, Sku, ReplicaCount, PartitionCount, Location | Export-Csv -Path $OutputCsvFilePath -Delimiter ';'
}
function Get-AzureRedisCacheBasicInfo {
param (
[string]$ResourceGroupName,
[string]$OutputCsvFilePath
)
$searchService = Get-AzRedisCache -ResourceGroupName $ResourceGroupName
$searchService | Select-Object -Property Name, Sku, Size, Location | Export-Csv -Path $OutputCsvFilePath -Delimiter ';'
}
################# Functions. End
# Opens Login popup
Connect-AzAccount
$azureSubscriptionId = Read-Host -Prompt "Enter Azure Subscription ID of the reviewed Resource Group";
Set-AzContext -SubscriptionId $azureSubscriptionId
$resourceGroupName = Read-Host -Prompt "Enter Resource Group name";
## Step #1
Get-WebAppsBasicInfo -ResourceGroupName $resourceGroupName -OutputCsvFilePath ".\HostingPlansInformation.csv"
## Step #2
#### Getting Azure SQL DBs info
Get-SqlBasicInfo -ResourceGroupName $resourceGroupName -OutputCsvFolderPath "."
## Step #3
#### Getting Azure Search info
Get-AzureSearchBasicInfo -ResourceGroupName $resourceGroupName -OutputCsvFilePath ".\AzureSearchInfo.csv"
## Step #4
#### Getting Redis Cache
Get-AzureRedisCacheBasicInfo -ResourceGroupName $resourceGroupName -OutputCsvFilePath ".\AzureRedisInfo.csv"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment