Skip to the main content.
Downloads Try Thriftly
Downloads Try Thriftly
Group 762

Migrate and run DataFlex applications with Oracle, MS SQL Server, PostgreSQL, MySQL &  MariaDB.

flex2Crystal

Stuck in Crystal XI?  Upgrade and use the latest versions of Crystal Reports with DataFlex applications. 

BTR2SQL

Convert from Btrieve / P.SQL / Actian transactional engines to Oracle, MS SQL Server, and PostgreSQL

thriftly-1

Quickly build multi-protocol web services with the same API. Supports JSON-RPC, REST, SOAP,  Thrift, and gRPC.

 Group 671-1

 

Why Mertech?

3 min read

Manage Thriftly APIs using Azure API management service

Manage Thriftly APIs using Azure API management service

Microsoft Azure's API Management is a platform for managing and monitoring APIs. Azure API Management allows developers to extend their public API by adding a layer of business insights, analytics, security and protection without having to write any additional code.

Thriftly provides support for managing APIs using Azure API Management without requiring developers to write any extra code, thanks to built-in Web Application Description Language (WADL) support.

This article outlines how you can publish and manage a Thriftly API using the Azure Management platform by simply pasting the Thriftly service URL into the Azure API Management module.

What is a WADL file?

A WADL file is composed of XML that describes a HTTP-based web service, like a Thriftly Gateway API. All the information required to describe your API, such as a function's parameters and their return types are described in this file. Thriftly allows you to add the “?wadl” parameter to the end of any service address to access the WADL file.

For example, following the Primitives Thriftly API example at https://gateway-tx-1.thriftly.io/ThriftlySamples/Primitives opens the APEye testing interface for an API that manipulates primitives.

If we append the ?wadl parameter to a Thriftly Gateway URL (making it look like this:
https://gateway-tx-1.thriftly.io/ThriftlySamples/Primitives?wadl) and refresh, a WADL file describing the API automatically downloads.

Wadl file

This allows other web services that have WADL support to easily consume your API. Thankfully, Azure API Management allows you to create an API service simply by importing this WADL file. We'll import the Thriftly Primitives API Sample onto Microsoft’s Azure platform, and you can follow the same steps to import your custom Thriftly API.

1. Create Azure API Management

If you don't already have a Microsoft Azure account, you'll have to sign up for one at Azure's home portal. Otherwise, log into your account. Once you're logged into Azure, create a new API by finding the ‘API Management’ module.

Azure Dashboard

When filling out the API Management Service form, be sure to choose the Location nearest your Thriftly Gateway location. This way there is less network overhead when a request reaches your API through Azure. In this example, we've chosen a central US location, since the Thriftly Sample Gateway API is running through the Texas location.

Create API Service



2. Import Thriftly into Azure

After submitting the API management service form, make your way to the Publisher Portal so we can import your Thriftly API. Find and follow the ‘Import API’ link on top the Publisher Portal dashboard.

Publisher

When you import the Thriftly API, you have a few options:

  • Upload the WADL file
  • Copy and paste the content
  • Copy and paste the URL with the WADL parameter.

We will simply copy the Thriftly WADL URL for the Primitives API at https://gateway-tx-1.thriftly.io/ThriftlySamples/Primitives?wadl and submit the form.

Import Thriftly API

3. Testing Your Thriftly API Through Azure

We're almost ready to start testing the API. But first, we need to add our newly created API to a product on Azure. A product in API management has different business rules that a customer must be subscribed to in order to use your API. By default, Azure creates a starter product with some limitations and an unlimited product.

We need to add our API to one of these products because when we call the API, we will be passing a subscription key used to apply certain business rules. This subscription key acts as a form of authorization to prevent non-subscribers from calling your API.

For example, the starter product states that a subscriber can run up to 5 calls per minute with a maximum of 100 calls per week. Select either the starter or unlimited product and assign your API.

API Products

Add Product


Once you've added your API to your products, go back to the API testing section in the Developer Portal to see the API calls that were imported. The Azure Developer Portal provides code examples in C#, Java, JavaScript, PHP, Python, and Ruby to call your API through Azure. Since you are logged in, the subscription keys will automatically populate in the required Ocp-Apim-Subscription-Key header. You can also see your subscription key under the profile dropdown link under your username.

Azure Testing Interface

Click on AddStrings and add a request body. We will send over a simple JSON-RPC body to call the AddString API call that will concatenate two strings together. Add this JSON-RPC body to the request body and send.

{
"jsonrpc": "2.0",
"method": "AddStrings",
"params": {
"first_str": "HELLO ",
"second_str": "WORLD " },
"id": 1
}

What’s Next?

With that, we've successfully called a Thriftly API through Azure. Azure’s API Management provides many features to extend your public Thriftly API. It can add throttling, so a single account or user can't consume all available bandwidth or CPU time. You're able to set limits on the number of calls per second. Azure allows you to “rewrite” the interface of your API, which allows you to change the exposed API in order to support the needs of a specific client or even a third party integration.


Result Using Azure and Thriftly


Result

The Thriftly Gateway allows you to easily publish APIs that can be shared to clients all over the world.

Microsoft's Azure API Management provides a suite of features to extend your Thriftly API’s capabilities and use your API to generate new revenue streams. Please visit the Thriftly Developer Forum if you have any additional questions regarding Thriftly or Azure API Management.

Helpful Links:
Azure API Docs

Try Thriftly with Azure's API Management Service now!

New call-to-action

Legacy Application Modernization: Key Steps, Benefits & Best Practices

Legacy Application Modernization: Key Steps, Benefits & Best Practices

This blog post was co-authored with Riaz Merchant, President and CEO at Mertech. In the fast-paced software world, 'legacy' often signals a warning.

Read More
Hybrid Cloud Migration: Plan, Process and Advantages

Hybrid Cloud Migration: Plan, Process and Advantages

This post was co-authored with Riaz Merchant, President/CEO at Mertech Data Systems, Inc.

Read More
Financial Benefits of Cloud Migration & Hybrid Cloud Applications

Financial Benefits of Cloud Migration & Hybrid Cloud Applications

Shifting from your traditional legacy systems to the Cloud can be a game changer, as the benefits of cloud migration are numerous. Cloud computing...

Read More