Skip to main content

Hi All, I have a requirement for restarting an Azure webapp using REST API calls. Has anyone worked on such solution before? Please let me share some information to start.

I have no experience with this, but the API reference is here:

https://learn.microsoft.com/en-us/rest/api/appservice/web-apps/restart?view=rest-appservice-2023-12-01

I would personally get things working with Postman first, then migrate the REST call to AA.


That’s an interesting question, sravan.aluvala !

I think the following community members may be able to help 

@ChanduMohammad 

@Zaid Chougle 

@Tamil Arasu10 

@Paul Hawkins 

@Padmakumar 


Hi ​@sravan.aluvala ,

 

Please find the below 

 

🔧 Prerequisites

  1. Azure Subscription with access to the Web App.
  2. App Registration in Azure AD (to get client_idclient_secret, and tenant_id).
  3. Automation Anywhere A360 environment with access to the REST Web Services package.

🔐 Step 1: Register an App in Azure AD

  1. Go to Azure Portal → Azure Active Directory → App registrations → New registration.
  2. Name your app and register it.
  3. Note down:
    • Application (client) ID
    • Directory (tenant) ID
  4. Under Certificates & secrets, create a client secret and save it.

🔑 Step 2: Assign API Permissions

  1. Go to your app → API permissions → Add a permission.
  2. Choose Azure Service Management → Delegated permissions → user_impersonation.
  3. Click Grant admin consent.

🔁 Step 3: Get Azure Access Token

Use the following REST API call in A360 to get the token:

  • MethodPOST
  • URL:
    https://login.microsoftonline.com/{tenant_id}/oauth2/token
  • Headers:
    Content-Type: application/x-www-form-urlencoded
  • Body (form-data):
    grant_type=client_credentials
    client_id=YOUR_CLIENT_ID
    client_secret=YOUR_CLIENT_SECRET
    resource=https://management.azure.com/

🚀 Step 4: Restart the Azure Web App

Once you have the token, use this API call:

  • MethodPOST
  • URL:
    https://management.azure.com/subscriptions/{subscription_id}/resourceGroups/{resource_group}/providers/Microsoft.Web/sites/{webapp_name}/restart?api-version=2022-03-01
  • Headers:
    Authorization: Bearer <access_token>
    Content-Type: application/json

🤖 Step 5: Implement in Automation Anywhere A360

  1. Use REST Web Services → POST to get the token.
  2. Store the token in a variable.
  3. Use another REST Web Services → POST to call the restart API.
  4. Use Log to File or Message Box to confirm success.