How to Deploy as Google Cloud Function

◷ Reading Time: 6 minutes

You can deploy a project as a Google Cloud Function. By doing this, you can get the service URL of your project without needing to install FlexRule Server.

We are deploying this Decision Table as an example. 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 your project’s entry document.
In this example, the decision table is the entry document.

Click on the Package Builder.

Add your package details such as,

  • Package identifier
  • Package version
  • Service version
Go to Deployment tab and select Google Cloud Function.

Enter Google Cloud subscription details. For more information about Service Account Key refer to How to retrieve Google Cloud service account key.

For the Service Account Key, click on the key icon to open a file browser and locate your Service Account Key json file or the template json file as discussed below.

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 Google Cloud subscription details.

{
"Keypath": "C:\Downloads\fr-project-305102-3d18b1f31767.json",
"Bucket": "flexrule-service",
"Location": "us-west2"
}


If the specified Bucket doesn’t exist yet, it will create a new one under the selected region.

The location depends on Tier Pricing. Please refer to this link to find out more. If the service account key is not valid, the Location dropdown will be empty.

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. In 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.

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.

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

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://us-west2-fr-project-305102.cloudfunctions.net/age-service-132658713990376521/Execute/age-service/1/person growing state/1?code=i7shHfdqjFwzrxvQAFN3QV1B+8Oi+xDzruHl2pcbHhpR2+rp/A97rrUbaPLTSPyRMBSQB0k6PB9G3gmY6x/9lA==
  • Default Url: The default URL that can be used to call the service. It does not specify any service version
    e.g.
    https://us-west2-fr-project-305102.cloudfunctions.net/age-service-132658713990376521/Execute/age-service/1/person growing state?code=i7shHfdqjFwzrxvQAFN3QV1B+8Oi+xDzruHl2pcbHhpR2+rp/A97rrUbaPLTSPyRMBSQB0k6PB9G3gmY6x/9lA==
  • Services Url: Retrieve the list of available services
    e.g.
    https://us-west2-fr-project-305102.cloudfunctions.net/age-service-132658713990376521/Services/?code=pE46KvMUQg4jmKJWHofR6Ss4W4HtXBL5m5DZBp5ynESvgj3rGHPDgw6q/l0QpYMoyl2VRGYSMY2gxU1oyxYyJw==

Update an Existing App

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

First, specify the new Service Version. This should be different from the service version you have already deployed. The Identifier and its Version should be similar to the previous version.

Then add the following information under Deployment.

  • Update App: Select this if you want to update an app
  • Function Name: The name of the Function App (Copy the exact app name from Google Cloud)
  • 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 found in Google Cloud Platform, under Cloud Functions.

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

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

https://us-west2-fr-project-305102.cloudfunctions.net/age-service-132658713990376521/Execute/age-service/1/person growing state?code=i7shHfdqjFwzrxvQAFN3QV1B+8Oi+xDzruHl2pcbHhpR2+rp/A97rrUbaPLTSPyRMBSQB0k6PB9G3gmY6x/9lA==
Updated on June 1, 2022

Was this article helpful?

Related Articles