Connect to Zuora Data from Blazor Apps



Build ASP.NET Core Blazor C# apps that integrate with real-time Zuora data using standard SQL.

Blazor is a framework for developing modern, client-side web UIs using .NET technology. Instead of coding in JavaScript, developers can use the familiar C# language and .NET libraries to build app UIs.

The CData ADO.NET Provider for Zuora can be used with standard ADO.NET interfaces, such as LINQ and Entity Framework, to interact with live Zuora data. Since Blazor supports .NET Core, developers can use CData ADO.NET Providers in Blazor apps. In this article, we will guide you to build a simple Blazor app that talks to Zuora using standard SQL queries.

Install the CData ADO.NET Provider for Zuora

CData ADO.NET Providers allow users to access Zuora just like they would access SQL Server, using simple SQL queries.

Install the Zuora ADO.NET Data Provider from the CData website or from NuGet. Search NuGet for "Zuora ADO.NET Data Provider."

Create a Zuora-Connected Blazor App

Start by creating a Blazor project that references the CData ADO.NET Provider for Zuora

  1. Create a Blazor project on Visual Studio.
  2. From the Solution Explorer, right click Dependencies, then click Add Project Reference.
  3. In the Reference Manager, click the Browse button, and choose the .dll file of the installed ADO.NET Provider (e.g. System.Data.CData.Zuora.dll, typically located at C:\Program Files\CData\CData ADO.NET Provider for Zuora\lib etstandard2.0).

SELECT Zuora Data from the Blazor App

  1. Open the Index.razor file from the Project page.
  2. In a ZuoraConnection object, set the connection string:

    Zuora uses the OAuth standard to authenticate users. See the online Help documentation for a full OAuth authentication guide.

    Configuring Tenant property

    In order to create a valid connection with the provider you need to choose one of the Tenant values (USProduction by default) which matches your account configuration. The following is a list with the available options:

    • USProduction: Requests sent to https://rest.zuora.com.
    • USAPISandbox: Requests sent to https://rest.apisandbox.zuora.com"
    • USPerformanceTest: Requests sent to https://rest.pt1.zuora.com"
    • EUProduction: Requests sent to https://rest.eu.zuora.com"
    • EUSandbox: Requests sent to https://rest.sandbox.eu.zuora.com"

    Selecting a Zuora Service

    Two Zuora services are available: Data Query and AQuA API. By default ZuoraService is set to AQuADataExport.

    DataQuery

    The Data Query feature enables you to export data from your Zuora tenant by performing asynchronous, read-only SQL queries. We recommend to use this service for quick lightweight SQL queries.

    Limitations
    • The maximum number of input records per table after filters have been applied: 1,000,000
    • The maximum number of output records: 100,000
    • The maximum number of simultaneous queries submitted for execution per tenant: 5
    • The maximum number of queued queries submitted for execution after reaching the limitation of simultaneous queries per tenant: 10
    • The maximum processing time for each query in hours: 1
    • The maximum size of memory allocated to each query in GB: 2
    • The maximum number of indices when using Index Join, in other words, the maximum number of records being returned by the left table based on the unique value used in the WHERE clause when using Index Join: 20,000

    AQuADataExport

    AQuA API export is designed to export all the records for all the objects ( tables ). AQuA query jobs have the following limitations:

    Limitations
    • If a query in an AQuA job is executed longer than 8 hours, this job will be killed automatically.
    • The killed AQuA job can be retried three times before returned as failed.

    For example: OAuthClientID=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;Tenant=USProduction;ZuoraService=DataQuery;

  3. The code below creates a simple Blazor app for displaying Zuora data, using standard SQL to query Zuora just like SQL Server.

          @page "/"
          @using System.Data;
          @using System.Data.CData.Zuora;
          
          <h1>Hello, world!</h1>
          
          Welcome to your Data app.
          
          <div class="row">
              <div class="col-12">
          
                  @using (ZuoraConnection connection = new ZuoraConnection(
                    "OAuthClientID=MyOAuthClientId;OAuthClientSecret=MyOAuthClientSecret;Tenant=USProduction;ZuoraService=DataQuery;"))
                  {
                      var sql = "SELECT Id, BillingCity FROM Invoices WHERE BillingState = 'CA'";
                      var results = new DataTable();
          
                      ZuoraDataAdapter dataAdapter = new ZuoraDataAdapter(sql, connection);
                      dataAdapter.Fill(results);
          
                      <table class="table table-bordered">
                          <thead class="thead-light">
                              <tr>
                                  @foreach (DataColumn item in results.Rows[0].Table.Columns)
                                  {
                                      <th scope="col">@item.ColumnName</th>
                                  }
                              </tr>
                          </thead>
                          <tbody>
                              @foreach (DataRow row in results.Rows)
                              {
                                  <tr>
                                      @foreach (var column in row.ItemArray)
                                      {
                                          <td>@column.ToString()</td>
                                      }
                                  </tr>
                              }
                          </tbody>
                      </table>
                  }
              </div>
          </div>
        
  4. Rebuild and run the project. The ADO.NET Provider renders Zuora data as an HTML table in the Blazor app.

    At this point, you have a Zuora-connected Blazor app, capable of working with live Zuora data just like you would work with a SQL Server instance. Download a free, 30-day trial and start working with live Zuora data in your Blazor apps today.

Ready to get started?

Download a free trial of the Zuora Data Provider to get started:

 Download Now

Learn more:

Zuora Icon Zuora ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Zuora.