How to Deploy as an Azure Function

◷ Reading Time: 7 minutes

You can deploy a project as an Azure Function. By doing this, it will not be required to install FlexRule Server in order to get the service URL of your project.

For example, we are deploying this Decision Table. It takes a person’s age as an input and outputs the title according to the age range.

This is the input object of the decision table.

{
     "person":
     {
         "Age":0,
         "Title":null
     }
 }

The complete project is attached at the end of the page.

How to Deploy

Open the Project’s Entry Document

Open your project’s entry document.
In this example, the decision table is the entry document.

Open Package Builder

Click on the Package Builder.

Add your package details such as,

  • Package identifier
  • Package version
  • Service version

Go to Deployment tab and select Azure Function.

Enter Azure subscription details.

Optionally, you can create a JSON according to the following template and save it as a JSON file (.json). Then use the button to upload the created JSON file with Azure subscription details.
{
     ClientId: "123435a7-331f-4da7-bbe3-da50rer34383",
     ClientSecret: "vH.F3y-_3Ll1YSX7~WQz397fMwXtOEmp49",
     SubscriptionId:"6ckc658b-ea39-4f9d-a5vc-6c48902f90c9",
     TenantId:"14967fee-0cm3-4ewb-bv5a-f5e23ee2e234",
     Region:"Australia East",
     ResourceGroup:"dev grop"
 }

Download the cloud-deployment Runtime file from the FlexRule user portal’s Licenses section, if you haven’t downloaded it already (If you require a license, contact the support team).

Select the Runtime license file. The Runtime folder will be automatically taken from the Runtime path you have defined in your project.

Click Publish.

Once the package was created successfully, you will see a confirmation message.

The deployment will happen in the background. On the background task window, you will see the list of deployment tasks.

The complete list of deployment tasks can be seen along with their status.

View Deployment URLs

Click on View Task Result to see the results.

You will receive the URLs of the successful deployment.

  • Execute Url: The URL to be used to call the service
    e.g.
    https://defineagetitle-vgke35s.azurewebsites.net/api/Execute/defineagetitle/1/person growing state/1?code=YF/cCCUW/C6nIcqjszaTCYlIM8V5c4Kmr86t4PoFeyeZPNJTNIaRVQ==
  • Default Url: The default URL that can be used to call the service. It does not specify any service version
    e.g.
    https://defineagetitle-vgke35s.azurewebsites.net/api/Execute/defineagetitle/1/person growing state?code=YF/cCCUW/C6nIcqjszaTCYlIM8V5c4Kmr86t4PoFeyeZPNJTNIaRVQ==
  • Services Url: Retrieve the list of available services
    e.g.
    https://defineagetitle-vgke35s.azurewebsites.net/api/Services/?code=TM1SdEQWa9/VtGe47ejmpahEPJmnTmv/y9b2BbCh34eM6KYXT5oLdg==

Update an Existing App

Once you deploy a service, you can use the following options to update the service.

  • Identifier: This should be similar to the identifier name you provided on the initial deployment
  • Identifier Version: This should be similar to the identifier version you provided on the initial deployment
  • Service Version: This is the new service version which should be different from version you provided on the previous deployment

Then add the following information under the Deployment tab.

  • Update App: Select this if you want to update an app
  • Function App Name: The name of the Function App (Copy the exact app name from the Azure portal or from the execute URL)
  • Set as Default: If you want to set the version that you are about to publish as default, select this

Function App Name can be extracted from the execute/ service URL

https://defineagetitle-vgke35s. azurewebsites.net/api/Execute/defineagetitle/1/person growing state/1?code=YF/cCCUW/C6nIcqjszaTCYlIM8V5c4Kmr86t4PoFeyeZPNJTNIaRVQ==

Or get Function App Name from Azure Resource Group

Once the re-deployment is completed successfully, you can access the new version via the default URL.

Note that the default version does not specify a service version. We set the default to the latest deployment version.

https://defineagetitle-vgke35s.azurewebsites.net/api/Execute/defineagetitle/1/person growing state?code=YF/cCCUW/C6nIcqjszaTCYlIM8V5c4Kmr86t4PoFeyeZPNJTNIaRVQ== 

Troubleshooting

If there are any errors, you can see the specific task(s) with the error(s).

Select the errored task and click on View Task Result to see the detailed exception.

You will be able to see the detailed exception message.

If you select a task and click Repeat Task, you can re-run the selected task.

Once the deployment is completed you can see the completed status with the icon .

Updated on June 2, 2022

Article Attachments

Was this article helpful?

Related Articles