> ## Content Index
> Fetch the complete content index at: https://codeisahighway.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# HowTo: Perform POST call to Azure REST API using Invoke-AzureRmResourceAction PowerShell command
- URL: https://codeisahighway.com/howto-perform-post-call-to-azure-rest-api-using-invoke-azurermresourceaction-powershell-command/
- Published: 2016-04-25T12:12:00.000Z
- Updated: 2026-07-17T08:33:13.000Z
- Author: Stephane Lapointe
- Tags: PowerShell, Automation, Azure Resource Manager, Microsoft Azure, #Import 2023-07-11 16:44, #Import 2026-09-04 10:31, #Import 2026-09-04 13:56

Not long ago, one of my colleagues asked me how we could automate an action that was not quite available in the Azure PowerShell cmdlets. Sure we can use Azure REST API, meaning acquiring a bearer token and all, but if I have the choice, I prefer to stay away from this. I'll show you how to perform POST action on resources on Azure using **native** Azure PowerShell v1.x commands.

## Update

2019-09-24: You can use Invoke-AzResourceAction on `Az` Azure PowerShell Module.  
2019-09-24: Fixed Cdn purge code `@{ ContentPaths = @('/*') }`. Thanks   
Roland Le Franc for reporting the error.

# A little hidden gem

There is a hidden gem in the AzureRM.Resources commands named `Invoke-AzureRmResourceAction` and I use it from time to time to perform POST call against Azure REST APIs for functionalities that are not yet surfaced as native commands in PowerShell.  
![Invoke-AzureRmResourceAction command in Azure.RM.Resources module](https://codeisahighway.com/content/images/2016/05/AzureRm-Resources-Commands.png)

## How to use it

First, you need to determine what action you want to perform. To obtain the list of all available action you can execute the following command:

```powershell
Get-AzureRmProviderOperation -OperationSearchString * | Where { $_.Operation -like '*action' } | Format-Table

```

Let's say you are after the purge action of the Microsoft.Cdn resource provider, you can always do

```powershell
Get-AzureRmProviderOperation -OperationSearchString Microsoft.Cdn/* | Where { $_.Operation -like '*action' } | Format-Table

```

![List of available actions for Microsoft.Cdn resource provider](https://codeisahighway.com/content/images/2016/05/Get-AzureRmProviderOperation-Microsoft-Cdn.png)

You need to locate the desired action, and note what is the OperationName for it.

Finally how to invoke the purge command using `Invoke-AzureRmResourceAction`:

```powershell
Invoke-AzureRmResourceAction `
    -ResourceGroupName $ResourceGroupName `
    -ResourceType 'Microsoft.Cdn/profiles/endpoints' `
    -ResourceName $ProfileName/$EndpointName `
    -ApiVersion '2017-10-12' `
    -Action 'Purge' `
    -Parameters @{ ContentPaths = @('/*') } `
    -Force

```

Happy automation!

## Reference

- [MSDN - Get-AzureRmProviderOperation command reference](https://msdn.microsoft.com/en-us/library/mt603720.aspx?ref=codeisahighway.com)
- [MSDN - Invoke-AzureRmResourceAction command reference](https://msdn.microsoft.com/en-us/library/mt652481.aspx?ref=codeisahighway.com)