PowerShell script to remove logic app from the resource group

In this post I have mentioned how to use az power shell script to remove specific logic app or any other specific azure resources

$LogicAppNames = “#{ListOfLogicApp}”
$LogicAppNameArray = $LogicAppNames.Split(‘|’)
$ResourceGroup = #{AzureDeploymentResourceGroup}
$SubscriptionID = “#{AzureSubscriptionID}”
az login –service-principal -u #{AzureApplicationID} -p #{AzureKey} –tenant #{DeploymentUserADTenantId}
foreach($logicapp in $LogicAppNameArray)
{
Write-Host “Deleting Logic app… “, $logicapp
$path = “https://management.azure.com/subscriptions/$SubscriptionID/resourceGroups/$ResourceGroup/providers/Microsoft.Logic/workflows/$logicapp”
$pathwithAPI = $path + “?api-version=2016-06-01”
Write-Host “Path =”, $pathwithAPI
az rest -m delete –header “Accept=application/json” -u $pathwithAPI
}

#(ListofLogicApp} -> Provide logic app name with the pipe delimited example logicapp1|logicapp2|logicapp3

#{AzureApplicationID} -> App Registered application id (Client ID of the application) – Make sure this app has right access for deployments.

#{AzureKey } -> Secret key for AzureApplicationID.

#{DeploymentUserADTenantId} -> Tenant Id.

Microsoft.Logic/workflows -> This is for the logic app flow. If we want to remove other azure services then we need to provide correct url. These url can be evaluated using resources.