Azure FarmBeats client library for .NET
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.
Install the package
Install the Azure FarmBeats client library for .NET with NuGet:
dotnet add package Azure.Verticals.AgriFood.Farming --prerelease
To use this package, you must have:
Authenticate the client
Using Azure Active Directory
This document demonstrates using DefaultAzureCredential to authenticate via Azure Active Directory. However, any of the credentials offered by the Azure.Identity will be accepted. See the Azure.Identity documentation for more information about other credentials.
Once you have chosen and configured your credential, you can create instances of any client types, for example,
var credential = new DefaultAzureCredential(); var client = new FarmClient(new Url("https://<my-account-name>.farmbeats.azure.net"), credential);
Basic understanding of below terms will help to get started with FarmBeats client library.
Farm hierarchy is a collection of below entities.
- Farmer - 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 farmer as the root. The hierarchy includes Farmer -> Farms -> Fields -> Seasonal Fields -> Boundaries -> Associated data (satellite, weather, farm operations). Cascade delete refers to the process of deleting any node and its subtree.
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).
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.
Operations exposed by the FarmBeats SDK for .NET use protocol methods to expose the underlying REST operations. You can learn more about how to use SDK Clients which use protocol methods in our documentation.
We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.
The following section shows you how to initialize and authenticate your client, then list all of your data sources.
List All Farmers
var credential = new DefaultAzureCredential(); var client = new FamersClient(new Uri("https://<my-account-name>.farmbeats.azure.net"), credential); var response = await client.ListAsync(); var responseDocument = JsonDocument.Parse(response.Content); Console.WriteLine(responseDocument.RootElement.GetProperty("value"));
Setting up console logging
The simplest way to see the logs is to enable the console logging. To create an Azure SDK log listener that outputs messages to console use AzureEventSourceListener.CreateConsoleLogger method.
// Setup a listener to monitor logged events. using AzureEventSourceListener listener = AzureEventSourceListener.CreateConsoleLogger();
To learn more about other logging mechanisms see here.
For more extensive documentation on the FarmBeats, see the [FarmBeats documentation][product_docs] on docs.microsoft.com.
This client SDK exposes operations using protocol methods, you can learn more about how to use SDK Clients which use protocol methods in our documentation.
See the [CONTRIBUTING.md][contributing] for details on building, testing, and contributing to this library.
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, visit cla.microsoft.com.
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 repos using our CLA.