Disable Logic App workflow using AZure REST API commands

Suganya Sivashanmugam 1 Reputation point
2021-11-18T06:50:28.177+00:00

I wanted to disable all the logic app workflows in a resource group. I re-searched and I could find only Set-AzLogicApp and the state of that can be enabled or disabled. Then Thought of using this REST API endpoint

POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{logicappName}/workflows/{workflowName}/disable?api-version=2016-06-01. When I use this command in my powershell command it throws an error "Please run 'az login' to setup account". If I use the az login command the pipeline in running on and on. So someone can help me on how to use the above command properly inside a powershell script.

My script is :

param(

 [string]
 $region,

 [string]
 $environment,

 [string]
 $subscriptionId,

 [string]
 $component
)

$resourceGroupName = "hip-core-$($region)-$($environment)"
$componentFullName = "la-$($component)-$($region)-$($environment)"

Write-Host "Resource group '$resourceGroupName' ";
Write-Host "Logic App Name '$componentFullName' ";

Write-Host "Getting subscription Id.....";
Set-AzContext -Subscription $subscriptionId

#Getting a specific workflow 
$workflowjson = az rest --method GET --uri https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Web/sites/{logicappname}/workflows/{workflowName}?api-version=2016-06-01
$workflows = $workflowsjson | ConvertFrom-Json
$workflowFullName = $_.Name
Azure Logic Apps
Azure Logic Apps
An Azure service that automates the access and use of data across clouds without writing code.
2,845 questions
Microsoft Partner Center API
Microsoft Partner Center API
Microsoft Partner Center: A Microsoft website for partners that provides access to product support, a partner community, and other partner services.API: A software intermediary that allows two applications to interact with each other.
313 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,364 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Pramod Valavala 20,591 Reputation points Microsoft Employee
    2021-11-20T12:10:25.013+00:00

    @Suganya Sivashanmugam There are various authentication methods available when writing powershell scripts. You could adopt the one that best suits your case.

    The cmdlet is indeed Set-AzLogicApp that you need to enable/disable logic apps though. This would be much simpler to use compared to making the REST API call directly (the cmdlet does the same internally, more or less).

    0 comments No comments

  2. Suganya Sivashanmugam 1 Reputation point
    2021-11-22T13:39:18.887+00:00

    Hi @pramodValavala Thanks for your reply. But I wanted to disable the workflow of the logic apps and not the logic app itself. I think set-logic app command is used to disable the whole Logic App. That is the reason I am using the REST API cmdlet so that I will be able to disable the workflow. Or is there any other option I could use to disable the workflows of a logic app? If so please to comment me. Thanks.

    0 comments No comments

  3. Limitless Technology 39,356 Reputation points
    2021-12-16T17:31:13.037+00:00

    Are you seeing anything when run az account list?
    It is possible that the credential used to login has no subscriptions. Terminal client type should not matter.
    This might not be a browser issue, but a problem of cached login credentials across your different browsers.


    --If the reply is helpful, please Upvote and Accept it as an answer--

    0 comments No comments