This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#get the health of the whole resource group | |
# Add each health status to a hashtable before output a complete table with all resource groups and their resource health | |
$resourceGroupHealth = @{} | |
foreach ($ResourceGroup in $ResourceGroups) { | |
#Set resource group name and use it in our url | |
$health = Invoke-RestMethod -Uri "https://management.azure.com/subscriptions/$subscriptionID/resourceGroups/$ResourceGroup/Providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2015-01-01" -Method GET -Headers $authHeader | |
$currentHealth = @{} | |
$currentHealth = @{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Azure functions powershell http trigger | |
#Get input | |
$input = Get-Content $req -Raw | ConvertFrom-Json | |
[int]$tempLow = $input.tempLow | |
[int]$heatingMinutes = $input.heatingMinutes | |
function send-altoxCommand { | |
param ( | |
[Parameter(Mandatory = $true)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function send-altoxCommand { | |
param ( | |
[Parameter(Mandatory = $true)] | |
$command, | |
[Parameter(Mandatory = $true)] | |
$pass, | |
[Parameter(Mandatory = $true)] | |
$email, | |
[Parameter(Mandatory = $true)] | |
$id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$alertRules = Invoke-RestMethod -Method GET "https://management.azure.com/subscriptions/$SubscriptionId/resourcegroups/$ResourceGroupName/providers/microsoft.insights/alertrules?api-version=2016-03-01" -Headers $authHeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$result = Get-AADAppoAuthToken -ClientID $AzureApplicationID -ClientSecret $ClientSecret -TenantId $TenantId | |
$AuthKey = "Bearer " + ($result.access_token) | |
$authHeader = @{ | |
'Content-Type' = 'application/json' | |
'Accept' = 'application/json' | |
'Authorization' = $AuthKey | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$Alert = $alertrules.id | |
(Invoke-RestMethod -Method GET "https://management.azure.com/$alert/incidents?api-version=$apiversion" -Headers $authHeader).value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param ( | |
# Your azure ad application ID | |
[Parameter(Mandatory)] | |
[String] | |
$AzureApplicationID, | |
# Azure AD application secret | |
[Parameter(Mandatory)] | |
[String] | |
$ClientSecret, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Creates an azure ad application and sets reader permissions on subscription | |
.NOTES | |
Script is provided as an example, it has no error handeling and is not production ready. App name and permissions is hard coded. | |
#> | |
param( | |
[Parameter(Mandatory)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# POST method: $req | |
$requestBody = Get-Content $req -Raw | ConvertFrom-Json | |
## validate event grid as described in https://docs.microsoft.com/en-us/azure/event-grid/security-authentication | |
# check event type and return a Json object with the correct validation response | |
if ($requestBody.eventType -eq "Microsoft.EventGrid.SubscriptionValidationEvent") { | |
$code = $requestBody.data.validationCode | |
$content = @{ validationResponse = $code } | |
$message = convertto-json -compress -InputObject ([ordered]@{ | |
body = $content |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.Synopsis | |
Example code on how to post messages to a custom event grid topic | |
.Notes | |
part of a blog article on https://adatum.no | |
#> | |
$eventDate = get-date -Format s # get the date and time for the event. Has to be sortable for event grid to accept. Pass as a string | |
$eagSASkey = "HCDs7UFipbBXZ0OPc+mM=2" # access key. |
OlderNewer