At the end of the day, like most APIs you encounter in the wild, Google services are exposed as standard REST endpoints. If you know how to create, authenticate, and issue an HTTP request, you have everything you need to add Google’s extensive list of services (including the Google Cloud Platform) to your applications.
However, most developers prefer to spend their time focused on the implementation of their application, and would rather skip mucking around with boilerplate code to create raw HTTP requests, serialize requests and responses, and handle errors. Depending on how many services an application consumes, such operations can represent a significant amount of development time.
Fortunately, like most popular public APIs, Google offers a Software Development Kit (SDK) for a majority of their services, for many different languages and platforms, including .NET via C#. In fact, the Google APIs Client Library for .NET has been around for a while, offering C# libraries for Google Services including the Google Cloud Platform.
Brand New Libraries for Google Cloud Platform
The Client Library for .NET offers a collection of libraries for accessing established services like YouTube, Calendar, etc. However, although this library collection does include support for various Google Cloud services, there is now a new set of .NET libraries for the Google Cloud Platform available here: https://cloud.google.com/dotnet
The new C# libraries, led by noted C# expert and Microsoft MVP Jon Skeet, offer a full-featured C# experience for developers looking to leverage GCP in their applications. These libraries are also open source, and available on GitHub for developers to clone as well and contribute to the project. There is also API documentation available including the list of supported products and their release status (beta, alpha, etc.).
As of the writing of this post, the original .NET Client Library is still supported for GCP, and many of the new libraries are in beta or alpha stages. However, it is still recommended that you leverage the new libraries, especially for new projects, as these are the libraries that will be updated and supported in the future.
Getting Started Guides
Each supported product has a page to get you started, documenting installation, authentication, and even sample code demonstrating usage of the library. These are linked from both the project Github homepage and the API Documentation page.
As of the writing of this post, the following libraries are available, separated by release status:
- Google Cloud PubSub
- Google Cloud Natural Language
- Stackdriver Monitoring
- Stackdriver Error Reporting
- Stackdriver Trace
- Google Cloud Diagnostics for ASP.NET
Each of the Google Cloud libraries is available via Nuget, so adding them to your project is as simple as right-clicking your project, selecting Manage Nuget Packages, and searching for the desired library.
Note: Be sure to select the option to “Include prerelease” since many of these libraries are still in beta/alpha stages.
It’s also important to note that your search may reveal the original libraries for .NET, so be sure you’re selecting the correct library (many of the new packages serve as wrappers to the older libraries, so they may also be included as dependencies). The newer libraries have an updated logo and namespace, so be sure to look carefully at the naming to ensure you’ve selected the correct one.
As a helpful resource to get you started, Google has created a complete C# sample that leverages several cloud services together in one project for you to test, run and deploy to GCP. There is also an associated, thoroughly detailed, step-by-step tutorial available that guides you through each facet of the project as well as the Google services they leverage. You get a full tour of several services including live deployment and even resource scaling.
If you’re new to GCP, this is a fantastic place to start, so I encourage you to read through the entire interactive tutorial to quickly get familiar with the Google Cloud Platform.
In addition, there is a collection of C# samples available on Github here: https://github.com/GoogleCloudPlatform/dotnet-docs-samples
Wrapping up and Next Steps
The Google Cloud Platform has a lot to offer C# developers, and the library refresh makes it easier than ever to integrate these services into your applications. Although still in early form, these libraries are growing quickly, both in terms of availability and quality, and easily installable via Nuget so you can start using these today!
However, although installation of the supported libraries into your own projects is easy enough, there’s an important step we have to complete before they can actually be used: Authentication. That will be the subject of a future post so stay tuned!
Until then, as always, I hope this was helpful, and thanks for reading!
Latest posts by Falafel Posts (see all)
- Matching Complex Query String Rewrite Rule in IIS - March 22, 2017
- Disable Content Filters in Sitefinity - March 8, 2017
- On Sitefinity Custom Widget Caching - February 22, 2017
- Dynamic Content Detail Widget Templates in Sitefinity - February 8, 2017
- Using Google Services in UWP C# Apps – Part 2 - February 7, 2017