Azure FarmBeats client library for Java - version 1.0.0-beta.3

FarmBeats is a B2B PaaS offering from Microsoft that makes it easy for AgriFood companies to build intelligent digital agriculture solutions on Azure. FarmBeats allows users to acquire, aggregate, and process agricultural data from various sources (farm equipment, weather, satellite) without the need to invest in deep data engineering resources.  Customers can build SaaS solutions on top of FarmBeats and leverage first class support for model building to generate insights at scale.

Use FarmBeats client library for Python to do the following.

  • Create & update parties, farms, fields, seasonal fields and boundaries.
  • Ingest satellite and weather data for areas of interest.
  • Ingest farm operations data covering tilling, planting, harvesting and application of farm inputs.

Source code | Package (Maven) | Product Documentation | Samples

Getting started


Include the Package


Authenticate the client

Using Azure Active Directory

In order to interact with the Azure FarmBeats service, your client must present an Azure Active Directory bearer token to the service.

The simplest way of providing a bearer token is to use the DefaultAzureCredential authentication method by providing client secret credentials is being used in this getting started section but you can find more ways to authenticate with [azure-identity][azure_identity].

You can authenticate with Azure Active Directory using the [Azure Identity library][azure_identity].

To use the [DefaultAzureCredential][DefaultAzureCredential] provider shown below, or other credential providers provided with the Azure SDK, please include the azure-identity package:


Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET.

Example - Create Parties Client
String endpoint = "https://<farmbeats-endpoint>";

// Create Parties Client
PartiesClientBuilder partiesBuilder = new PartiesClientBuilder()
    .credential(new DefaultAzureCredentialBuilder().build());
PartiesAsyncClient partiesClient = partiesBuilder.buildAsyncClient();

Example - Create Boundaries Client
// Create Boundaries Client
BoundariesClientBuilder boundariesBuilder = new BoundariesClientBuilder()
    .credential(new DefaultAzureCredentialBuilder().build());
BoundariesAsyncClient boundariesClient = boundariesBuilder.buildAsyncClient();
Example - Create Scenes Client
// Create Scenes Client
ScenesClientBuilder scenesBuilder = new ScenesClientBuilder()
    .credential(new DefaultAzureCredentialBuilder().build());
ScenesAsyncClient scenesClient = scenesBuilder.buildAsyncClient();

Key concepts

Basic understanding of below terms will help to get started with FarmBeats client library.

Farm Hierarchy

Farm hierarchy is a collection of below entities.

  • Party - is the custodian of all the agronomic data.
  • Farm - is a logical collection of fields and/or seasonal fields. They do not have any area associated with them.
  • Field - is a multi-polygon area. This is expected to be stable across seasons.
  • Seasonal field - is a multi-polygon area. To define a seasonal boundary we need the details of area (boundary), time (season) and crop. New seasonal fields are expected to be created for every growing season.
  • Boundary - is the actual multi-polygon area expressed as a geometry (in geojson). It is normally associated with a field or a seasonal field. Satellite, weather and farm operations data is linked to a boundary.
  • Cascade delete - Agronomic data is stored hierarchically with party as the root. The hierarchy includes Party -> Farms -> Fields -> Seasonal Fields -> Boundaries -> Associated data (satellite, weather, farm operations). Cascade delete refers to the process of deleting any node and its subtree.


// Create Party
JSONObject object = new JSONObject().appendField("name", "party1");
BinaryData party = BinaryData.fromObject(object);
partiesClient.createOrUpdateWithResponse("contoso-party", party, null).block();

// Get Party
Response<BinaryData> response = partiesClient.getWithResponse("contoso-party", new RequestOptions()).block();

// Create Boundary
BinaryData boundary = BinaryData.fromString("{\"geometry\":{\"type\":\"Polygon\",\"coordinates\":[[[73.70457172393799,20.545385304358106],[73.70457172393799,20.545385304358106],[73.70448589324951,20.542411534243367],[73.70877742767334,20.541688176010233],[73.71023654937744,20.545083911372505],[73.70663166046143,20.546992723579137],[73.70457172393799,20.545385304358106]]]},\"name\":\"string\",\"description\":\"string\"}");
response = boundariesClient.createOrUpdateWithResponse("contoso-party", "contoso-boundary", boundary, null).block();


Scenes refers to images normally ingested using satellite APIs. This includes raw bands and derived bands (Ex: NDVI). Scenes may also include spatial outputs of an inference or AI/ML model (Ex: LAI).


// Trigger Satellite job and wait for completion
BinaryData satelliteJob = BinaryData.fromString("{\"boundaryId\":\"contoso-boundary\",\"endDateTime\":\"2022-02-01T00:00:00Z\",\"partyId\":\"contoso-party\",\"source\":\"Sentinel_2_L2A\",\"startDateTime\":\"2022-01-01T00:00:00Z\",\"provider\":\"Microsoft\",\"data\":{\"imageNames\":[\"NDVI\"],\"imageFormats\":[\"TIF\"],\"imageResolutions\":[10]},\"name\":\"string\",\"description\":\"string\"}");
scenesClient.beginCreateSatelliteDataIngestionJob("contoso-job-46856", satelliteJob, null).getSyncPoller().waitForCompletion();
System.out.println(scenesClient.getSatelliteDataIngestionJobDetailsWithResponse("contoso-job-46856", null).block().getValue());

// Iterate through ingested scenes
Iterable<BinaryData> scenes = scenesClient.list("Microsoft", "contoso-party", "contoso-boundary", "Sentinel_2_L2A", null).toIterable();
scenes.forEach(scene -> System.out.println(scene));

Farm Operations

Fam operations includes details pertaining to tilling, planting, application of pesticides & nutrients, and harvesting. This can either be manually pushed into FarmBeats using APIs or the same information can be pulled from farm equipment service providers like John Deere.


More examples can be found in samples.


Enabling Logging

Azure SDKs for Java offer a consistent logging story to help aid in troubleshooting application errors and expedite their resolution. The logs produced will capture the flow of an application before reaching the terminal state to help locate the root issue. View the logging wiki for guidance about enabling logging.

Next steps

For more extensive documentation please check our Product Documentation.


For details on contributing to this repository, see the contributing guide.

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, view Microsoft's CLA.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repositories using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.