Blog Post

Azure Integration Services Blog
2 MIN READ

Enabling Service Bus and SAP built-in connectors for stateful Logic Apps in Standard

edwardyhe's avatar
edwardyhe
Icon for Microsoft rankMicrosoft
May 12, 2023

Service Bus and SAP built-in connectors in Logic App Standard contain many triggers and actions that were previously restricted to stateless Logic Apps only. Beginning in April, these triggers and actions are now available for use in stateful Logic Apps. This article explains the requirements needed to successfully use this new feature.

 

Some Service Bus and SAP built-in connector triggers and actions were not previously enabled in stateful workflows as they required triggers and/or actions to be performed by the same instance. This was done by default in stateless workflows but was far from guaranteed in stateful workflows previously. With the update in April, we have added a framework for stateful workflows to be able to complete these requirements, which allows us to enable these connector triggers and actions for stateful workflows.

 

This feature depends on communication between instances to maintain connection context. For security, the associated Logic App must be contained within a VNet, and a site configuration needs to be set. We are working to automatically set this site configuration for customers in the future. In the meantime, please follow the below instructions:

 

Instructions

  • Enable VNet integration for the Logic App and place it in subnet

Adding VNet integration in portal.

  • Update site config via ARM API.

    • HTTP method is PATCH
    • The resourceId is of the form: subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/config/web
    • A sample URI for the request is: 
      https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourcegroups/test-rg/providers/Microsoft.Web/sites/test-site/config/web?api-version=2021-02-01
    • Authorization is required (OAuth). The bearer token can be obtained from the portal in browser from Developer Tools (F12), and obtaining the token from any management request, for example when saving a workflow.
    • HTTP content is: {"properties": {"vnetPrivatePortsCount": "2"}}
  • To prevent loss of context during scaling in, fix the number of instances available in the logic app. Set the number of always ready instances to be equal to the maximum scale out limit and maximum burst.

Preventing scale-in events.

Alternative method to update site config via Powershell

This method circumvents the need to manually obtain the bearer token.
Replace {subscriptionId} and {resourceId} with your subscriptionId and resourceId (see above for resourceId format).

  Set-AzContext -Subscription {subscriptionId}
  $webConfig = Get-AzResource -ResourceId {resourceId}
  $webConfig.Properties.vnetPrivatePortsCount = 2
  $webConfig | Set-AzResource -ResourceId {resourceId}

If you get the error:

  Set-AzResource :
  {
    "Code":"BadRequest",
    "Message":"siteConfig.ReservedInstanceCount is invalid.  Please use the new property siteConfig.PreWarmedInstanceCount.",
    "Target": null,
    "Details":
    [
      {
        "Message":"siteConfig.ReservedInstanceCount is invalid. Please use the new property siteConfig.PreWarmedInstanceCount."
      },
      {
        "Code":"BadRequest"
      },
      {
        "ErrorEntity":
        {
          "ExtendedCode":"51021",
          "MessageTemplate":"{0} is invalid. {1}",
          "Parameters":
          [
            "siteConfig.ReservedInstanceCount", "Please use the new property siteConfig.PreWarmedInstanceCount."
          ],
          "Code":"BadRequest",
          "Message":"siteConfig.ReservedInstanceCount is invalid. Please use the new property siteConfig.PreWarmedInstanceCount."
        }
      }
    ],
    "Innererror": null
  }

Workaround with:

  $webConfig.Properties.preWarmedInstanceCount = $webConfig.Properties.reservedInstanceCount
  $webConfig.Properties.reservedInstanceCount = $null
  $webConfig | Set-AzResource -ResourceId {resourceId}
Updated May 12, 2023
Version 2.0

28 Comments

  • dmakeyman's avatar
    dmakeyman
    Copper Contributor

    Hi all and AndrasRatz

     

    Please follow very carrefully the way to get the Id of the ressource ! (it is not a copy/paste on the logicapp resourceId 😞 , I do the same and got the same result as you 

     

    • form: subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Web/sites/{siteName}/config/web

    you have to add /config/web at the end of the ResourceId which is given in logicapp panel  , then you'll find the property 

     

  • AndrasRatz's avatar
    AndrasRatz
    Copper Contributor

    edwardyhe  I received the same error message and even though I already have vnet setup. I've tried the power shell solution, but I get the error for 

    $webConfig.Properties.vnetPrivatePortsCount = 2

     

    SetValueInvocationException: Exception setting "vnetPrivatePortsCount": "The property 'vnetPrivatePortsCount' cannot be found on this object. Verify that the property exists and can be set."

     

    Any other solution?

  • Dhana1207 : This feature is not yet supported on containers, there are plans to have this feature supported eventually but there is no ETA right now.

  • SumitGaur680 : The app setting is used solely for the affinity feature, it will not affect any other trigger/action/workflows. I suspect that there are other causes to why you see unusual behavior in the blob trigger/ peeklock history.

    "if i remove this setting, then my logic app starts working only issue that i face is the workflow cannot complete/ dead letter the message. 

    any suggestion how this can be fixed?": This is expected since the setting is needed to run stateful service bus with more than one worker/instance
    "the error i see on app-insight is : The listener for function 'Functions.WorkflowDispatcher' was unable to start. An attempt was made to access a socket in a way forbidden by its access permissions.": I will need more information on this e.g. is this with the setting enabled or disabled, what is the scenario you are using?

     

    Dhana1207 : I am unfamiliar with using logic apps standard on container instances and whether or not we are currently supporting this scenario. Let me reach out to some other members of the team to learn more about this and get back to you (please leave another message here if you do not hear back from me in a week). 

  • Dhana1207's avatar
    Dhana1207
    Copper Contributor

    edwardyhe  Thanks for this useful article.

    in Logicapp std , we were able to resolve the issue by enabling Vnet and setting the configuration as you suggested in this blog. But We have a requirement to containerize same standard logic app workflows which uses service bus built in connector . we were able to push the image and test, but Complete message action is failing with bad request error. As a solution suggested for Standard logic apps , we tried implementing the same solution for Container instance by adding vnet and subnet, apart from this we need to set vnetPrivatePortCount to 2 but this property is not available for the container instance. Any suggestions would be helpful.

  • SumitGaur680's avatar
    SumitGaur680
    Copper Contributor

    Hi edwardyhe , 

     

    i am having some issue with above setup, i currently have a logic app standard which uses service bus built-in connector, it i set the property WEBSITE_PRIVATE_PORTS = 2 on my logic app instance, i see one of my workflows which uses a blob trigger do not move ahead after the trigger stage and shows up as running and i need to cancel the run.  in other workflow where i have service bus peek lock trigger, the trigger gets fired but there is no new instances on the run history. 

    if i remove this setting, then my logic app starts working only issue that i face is the workflow cannot complete/ dead letter the message. 

    any suggestion how this can be fixed?

     

    the error i see on app-insight is : The listener for function 'Functions.WorkflowDispatcher' was unable to start. An attempt was made to access a socket in a way forbidden by its access permissions.

     

     

  • Hi dmakeyman ,

    Logic Apps that were newly VNet integrated may have this setting set automatically. You can confirm whether this setting is set correctly by going into the Azure Portal -> Your logic app -> Advanced Tools -> Environment -> Search for "WEBSITE_PRIVATE_PORTS =". There should be two ports set here for SAP to work correctly.

  • dmakeyman's avatar
    dmakeyman
    Copper Contributor

    Hi 

     

    Thanks for the article , we put in place and the connection to SAP ( for us 😉 is working fine , but we have problem trying to register RFC server on ECC comming from logic app , and one thing we didn't do is setting 

    vnetPrivatePortsCount

     as for today , it doesn't exist on the property of the vnet ressource .. is it new? (was it removed ?) or do we had to add it ? (can we ?) 

     

    (I'm using the "alternative method" )