PowerShell Script to Delete API Operations in Azure API Management

API Management is a popular service on Azure that allows developers to create, manage, and secure APIs. When you have an Azure Function that you want to expose as an API, you can add it to API Management as an operation. However, if you delete the Azure Function, you should also remove the corresponding operation from API Management. Removing these api operations manually is a pain. You can below powershell script to remove those api operations. Remember to run the script before removing the function app. 

Code

You can get the latest code from Github.

Prerequisites

To follow along with this tutorial, you should have:

  • An Azure subscription
  • Azure PowerShell installed on your machine

Steps

Here are the steps to remove Azure Functions from API Management using PowerShell:

  1. Open PowerShell on your local machine
  2. Copy and paste the PowerShell script into your PowerShell window
  3. Replace the values for the following variables in the script:
    • $apimName
    • $apimRg
    • $apimApiName
    • $subId
    • $functionAppRg
    • $functionAppName
  4. Run the script by pressing the Enter key

Conclusion

API Management is a powerful service on Azure that can help you manage your APIs. When you have Azure Functions that you want to expose as APIs, you can add them to API Management as operations. However, if you delete the Azure Functions, you should also remove the corresponding operations from API Management. In this tutorial, we showed you how to do this using PowerShell. We hope you found it helpful!

You may also like...

Leave a Reply