About This Page
This page is part of the Azure documentation. It contains code examples and configuration instructions for working with Azure services.
Bias Analysis
Bias Types:
⚠️
powershell_heavy
⚠️
windows_tools
⚠️
missing_linux_example
⚠️
windows_first
Summary:
The documentation page demonstrates a strong Windows and PowerShell bias. All code samples and walkthroughs use PowerShell cmdlets, Windows-style file paths, and Windows-centric tooling (e.g., Az PowerShell module, Invoke-WebRequest, Get-Content). There are no examples using Linux-native tools (such as curl, wget, or bash scripting), nor are there any references to cross-platform or Linux command-line environments. REST API examples are also shown only via PowerShell, not with curl or other common Linux tools. The documentation assumes the user is on Windows or using PowerShell Core, and does not provide parity for Linux users.
Recommendations:
- Add equivalent examples using curl or wget for invoking webhooks and REST APIs from Linux/macOS.
- Provide bash or shell script samples for preparing JSON payloads and handling responses.
- Show how to authenticate and interact with Azure using Azure CLI (az) instead of only PowerShell Az module.
- Use platform-agnostic file paths (e.g., forward slashes) or clarify path differences for Windows vs. Linux.
- Explicitly mention that all examples are shown in PowerShell and provide links or tabs for Linux/bash alternatives.
- Include at least one full end-to-end example using only Linux-native tools to demonstrate parity.
Create pull request
Flagged Code Snippets
Get-AzAutomationWebhook `
-ResourceGroup $resourceGroup `
-AutomationAccountName $automationAccount `
-Name $psWebhook
# Sign in to your Azure subscription
$sub = Get-AzSubscription -ErrorAction SilentlyContinue
if(-not($sub))
{
Connect-AzAccount
}
# Invoke the REST API
# Store URL in variable; reveal variable
$response = Invoke-RestMethod -Uri $restURI -Method Put -Headers $authHeader -Body $body
$webhookURI = $response.properties.uri
$webhookURI
Invoke-WebRequest -Method Delete -Uri $restURI -Headers $authHeader
param
(
[Parameter(Mandatory=$false)]
[object] $WebhookData
)
write-output "start"
write-output ("object type: {0}" -f $WebhookData.gettype())
write-output $WebhookData
write-output "`n`n"
write-output $WebhookData.WebhookName
write-output $WebhookData.RequestBody
write-output $WebhookData.RequestHeader
write-output "end"
if ($WebhookData.RequestBody) {
$names = (ConvertFrom-Json -InputObject $WebhookData.RequestBody)
foreach ($x in $names)
{
$name = $x.Name
Write-Output "Hello $name"
}
}
else {
Write-Output "Hello World!"
}
# Sign in to your Azure subscription
$sub = Get-AzSubscription -ErrorAction SilentlyContinue
if(-not($sub))
{
Connect-AzAccount
}
# Initialize variables with your relevant values
$resourceGroup = "resourceGroupName"
$automationAccount = "automationAccountName"
$runbook = "runbookName"
$psWebhook = "webhookName"
# Create webhook
$newWebhook = New-AzAutomationWebhook `
-ResourceGroup $resourceGroup `
-AutomationAccountName $automationAccount `
-Name $psWebhook `
-RunbookName $runbook `
-IsEnabled $True `
-ExpiryTime "12/31/2022" `
-Force
# Store URL in variable; reveal variable
$uri = $newWebhook.WebhookURI
$uri
$resourceGroup = "resourceGroup"
$templateFile = "path\webhook_deploy.json"
$armAutomationAccount = "automationAccount"
$armRunbook = "ARMrunbookName"
$armWebhook = "webhookName"
$webhookExpiryTime = "12-31-2022"
New-AzResourceGroupDeployment `
-Name "testDeployment" `
-ResourceGroupName $resourceGroup `
-TemplateFile $templateFile `
-automationAccountName $armAutomationAccount `
-runbookName $armRunbook `
-webhookName $armWebhook `
-WebhookExpiryTime $webhookExpiryTime
# Initialize variables
$subscription = "subscriptionID"
$resourceGroup = "resourceGroup"
$automationAccount = "automationAccount"
$runbook = "runbookName"
$restWebhook = "webhookName"
$file = "path\webhook.json"
# consume file
$body = Get-Content $file
# Craft Uri
$restURI = "https://management.azure.com/subscriptions/$subscription/resourceGroups/$resourceGroup/providers/Microsoft.Automation/automationAccounts/$automationAccount/webhooks/$restWebhook`?api-version=2015-10-31"
# Obtain access token
$azContext = Get-AzContext
$azProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile
$profileClient = New-Object -TypeName Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient -ArgumentList ($azProfile)
$token = $profileClient.AcquireAccessToken($azContext.Subscription.TenantId)
$authHeader = @{
'Content-Type'='application/json'
'Authorization'='Bearer ' + $token.AccessToken
}
$response = Invoke-RestMethod -Uri $restURI -Method GET -Headers $authHeader
$response | ConvertTo-Json
$Names = @(
@{ Name="Hawaii"},
@{ Name="Seattle"},
@{ Name="Florida"}
)
$body = ConvertTo-Json -InputObject $Names
# Revise file path with actual path
$file = "path\names.json"
$bodyFile = Get-Content -Path $file
$response = Invoke-WebRequest -Method Post -Uri $webhookURI -Body $body -UseBasicParsing
$response
$responseFile = Invoke-WebRequest -Method Post -Uri $webhookURI -Body $bodyFile -UseBasicParsing
$responseFile
#isolate job ID
$jobid = (ConvertFrom-Json ($response.Content)).jobids[0]
# Get output
Get-AzAutomationJobOutput `
-AutomationAccountName $automationAccount `
-Id $jobid `
-ResourceGroupName $resourceGroup `
-Stream Output
Remove-AzAutomationWebhook `
-ResourceGroup $resourceGroup `
-AutomationAccountName $automationAccount `
-Name $psWebhook