Deploying and managing a REST API with Azure - Cloud

author
Talend Documentation Team
EnrichVersion
Cloud
EnrichProdName
Talend Cloud
task
Design and Development
Design and Development > Testing APIs
EnrichPlatform
Talend API Designer
Talend API Tester
Talend Management Console
Talend Studio

Deploying and managing a REST API with Azure

Once you have designed your API in Talend Cloud API Designer and created your service in Talend Studio, you can use Azure for load balancing and API management.

This document uses the DemoREST service available in Talend Studio to illustrate and end-to-end implementation. It explains how to:
  • Create Remote Engines on Azure Virtual Machines
  • Deploy a service on a Remote Engine cluster
  • Create a load balancer on Azure
  • Create an API management service on Azure

For more information on how to design an API and a data service, see Talend Cloud API Services Platform Getting Started Guide.

Creating Remote Engines for Azure

You can use the Talend Cloud Remote Engine for Azure offer in the Microsoft Azure marketplace to create a Virtual Machine with a Talend Remote Engine. For more detailed instructions, see Talend Cloud Remote Engine for Microsoft Azure Guide .

Before you begin

  • You have the relevant rights on Microsoft Azure.
  • You have the relevant rights on Talend Cloud.

Procedure

  1. In Talend Cloud Management Console, go to the Engines page and create two Remote Engines.
    You can name them DemoREST-RE1 and DemoREST-RE2 for example. Each Remote Engine should have at least the Microservice run profile.
  2. In Azure, go to the marketplace and create a Talend Cloud Remote Engine for Azure.
  3. In the Basics tab, select your subscription and create a new resource group named DemoREST-RG1, for example.
    To install your Remote Engines for Azure with this process, you need a separate resource group for each Remote Engine. If you want to have all your virtual machines in the same resource group, you need to create them and then install a Remote Engine on each. For more information, see the Azure Virtual Machines documentation.
  4. Name your virtual machine DemoREST-VM1 for example, and configure authentication settings.

    Example

  5. In the Virtual Machine Settings tab, create your storage account and public IP address.
    The public IP address SKU should match the load balancer that you want to use. It is Basic by default, for this example it should be changed to Standard.
  6. Configure your virtual network.
    You can create a virtual network while creating your first Remote Engine and then reuse it for the second one.

    Example

  7. In the Remote Engine Settings tab, enter the preauthorized key for your DemoREST-RE1 Remote Engine and select your region.
  8. Repeat the previous steps to create another Talend Cloud Remote Engine for Azure:
    1. Create a new resource group, DemoREST-RG2 for example.
    2. Name the virtual machine DemoREST-VM2.
    3. Use the same DemoREST-VNet virtual network created for the first virtual machine.
    4. Use the preauthorized key for the DemoREST-RE2 Remote Engine.

Results

The virtual machines are created and started, each with one of your Remote Engines installed and paired.

Creating an inbound port rule

Create a rule to allow external access to your virtual machines.

Procedure

  1. Open the DemoREST-VM1 virtual machine that you created and click Networking.
  2. Click Add inbound port rule to create a new rule.
  3. Configure the rule.
    In this example, the rule allows traffic from any source to any destination. It is configured as follows:
    Parameter Value
    Source Any
    Source port ranges *
    Destination Any
    Destination port ranges *
    Protocol Any
    Action Allow
    Priority 1010
    Name ExternalAccess
  4. Click Add.
    The new rule is added to the list of inbound port rules.
  5. Repeat the previous steps to create the same rule in DemoREST-VM2.

Deploying a microservice on a Remote Engine cluster

Create a Remote Engine cluster and import a microservice from Talend Studio to deploy it.

Before you begin

  • You have created Remote Engines.
  • You have installed Talend Studio.

About this task

In this example, the Job is deployed as a microservice, but you can also deploy it using Talend Runtime. To do so, you need to install an instance of Talend Runtime on each of your virtual machines and select the OSGi Bundle build type for your Job in Talend Studio.

Creating a Remote Engine cluster

Procedure

  1. In Talend Cloud Management Console, go to the Engines page and click ADD > Remote Engine cluster.
  2. Select the relevant environment and workspace.
  3. Enter a name for your cluster, DemoREST-REC for example.
  4. Click SAVE.
    The cluster is created, you can now add Remote Engines to it.
  5. Click your Remote Engine cluster in the Engines page to open the Cluster details panel, then click Engines.
  6. Click the pencil icon to the right of Remote Engines.
  7. Select the two Remote Engines you created.

    Example

Results

Your Remote Engine cluster is created and you can use it to deploy your service.

Importing the ESB demo project

Import demo Jobs, Routes and Services to Talend Studio.

About this task

Talend Studio comes with a several demo projects, which allow you to test different components and features.

Procedure

  1. In the Integration perspective of Talend Studio, click the icon.
  2. In the dialog box that opens, select ESB Demos and click Finish.

Results

The demo project is imported in the Repository. You can use the Jobs, Routes and Services to discover more Talend Cloud API Services Platform features.

Publishing the microservice to Talend Cloud

Before you begin

Your Talend Studio is connected to your Talend Cloud account.

Procedure

  1. In your Repository, expand the Job Designs > Standard nodes and open the DemoREST Job.
  2. Go to the Job tab and click Deployment.
  3. In the Build Type drop-down list, select Microservice for ESB.
  4. Save the Job.
  5. Right-click the Job in the Repository and click Publish to Cloud.
  6. Select the relevant workspace and click Finish.

Results

An artifact and a draft task are created in Talend Cloud Management Console. You can now configure and deploy the task.

Configuring and deploying the task

Procedure

  1. In Talend Cloud Management Console, go to the Management page and click Tasks in the relevant workspace.
  2. Open your DemoREST task and click EDIT.
  3. Make sure that the details in the Artifact step are correct and click CONTINUE.
  4. In the Runtime drop-down list, select your Remote Engine cluster.
  5. Select the Custom option for the port, and enter 5066 in the Port number field.
  6. Select the Parallel option for the deployment strategy.
  7. Click SAVE DRAFT.
  8. Make sure that all your Remote Engines are paired and available, then click DEPLOY.

Testing the microservice

Use Talend Cloud API Tester to test your deployed microservice.

Before you begin

You have installed the Talend Cloud API Tester Google Chrome extension. For more information, see the Talend Cloud API Tester User Guide.

Procedure

  1. Open Talend Cloud API Tester and click the Project button in the bottom of the left panel to create a new project.
  2. Enter a name for your project, DemoREST for example, and click Create.
  3. Click Add an environment in the top right corner of the window to create a new environment named DemoREST-VM1.
    This will allow you to create an environment variable for your base URL to avoid changing it directly in the requests.
  4. Enter baseURL in the Name column and the relevant URL in the Value column.
    In this example, enter http://<DemoREST-VM1>:5066/services and replace <DemoREST-VM1> with the public IP address associated with your virtual machine.
  5. Optional: Create an environment for DemoREST-VM2:
    1. Click Add an environment and enter a name.
    2. Select the Copy variables from check box and select DemoREST-VM1 in the drop-down list.
    3. Click Create.
    4. Update the Value column for the baseURL with the relevant IP address.
  6. Click Close.
  7. Click Add a request to create a request named Get all customers, then open the request and enter the following URI: ${"baseURL"}/customers.
  8. Click Save, then click Send to send the request.
    The list of customers is returned.