Here is my Code that got Azure App to work being able to Delete a Node from SWOrion
It's clunky and its ugly but it's mine.
Hope it helps someone.
using namespace System.Net# Input bindings are passed in via param block.
param($Request, $TriggerMetadata)
# Interact with query parameters or the body of the request
# to get the name of the VM to be removed from Solarwinds.
$nodename = $Request.Query.nodename
if (-not $nodename) {
$nodename = $Request.Body.nodename
}
#Variable Load
$SubscriptionName="AZURE-Subscription"
$KeyVaultName="KeyVaultNameSpace"
$SubscriptionContext = Get-AZContext -ListAvailable | Where-Object { $_.Subscription.Name -eq $SubscriptionName }
$SecretUsername = (Get-AZKeyVaultSecret -VaultName $KeyVaultName -Name "ServiceAccount-Username" -DefaultProfile $SubscriptionContext).SecretValueText
$SecretPassword = (Get-AZKeyVaultSecret -VaultName $KeyVaultName -Name "ServiceAccount-Password" -DefaultProfile $SubscriptionContext).SecretValueText
$SecretPassword =$SecretPassword | ConvertTo-SecureString -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($SecretUsername, $SecretPassword)
$hostname = "SolarwindsWebURL.Coml"
$query = "SELECT NodeID FROM Orion.Nodes WHERE NodeName LIKE '${nodename}'"
$fullquery = "https://${hostname}:17778/SolarWinds/InformationService/v3/Json/Query?query=$query"
$response = Invoke-RestMethod -Uri $fullquery -Credential $cred -ContentType "application/json" -SkipCertificateCheck
$NodeID = $response.results.NodeID
$uri = "https://${hostname}:17778/SolarWinds/InformationService/v3/Json/swis://databasename./Orion/Orion.Nodes/NodeID=$NodeID"
If($NodeID){
Invoke-RestMethod -Uri $uri -method Delete -Credential $cred -SkipCertificateCheck
}
#Success
if ($NodeID) {
$status = [HttpStatusCode]::OK
$body = "$nodename Has been removed from SAM"
}
#Failure
if (!$NodeID) {
$status = [HttpStatusCode]::OK
$body = "$nodename was not found in SAM"
}
# Associate values to output bindings by calling 'Push-OutputBinding'.
Push-OutputBinding -Name Response -Value ([HttpResponseContext]@{
StatusCode = $status
Body = $body
})