Overview of .NET on Google Cloud Platform

I consider myself a Java developer first but during my time at Microsoft and Skype, I had the chance to learn about C# and .NET. Over time, I started liking the advanced features in C# (that Java just recently started having) and the great ecosystem and tooling around .NET. 

When I moved to Google and started working on Google Cloud Platform, I was naturally very happy to learn that Google Cloud Platform supports .NET applications.

In this blog post, I want to provide an overview of .NET support on Google Cloud Platform and talk about .NET client library. 

If you want more details, .NET on Google Cloud Platform is the best page to get started, it includes quickstarts, code samples, tutorials and more.

Windows Server and ASP.NET

First question you probably have is: What kind of .NET applications can I host on Google Cloud and how? You can host ASP.NET applications on Windows Server running on Compute Engine.

The easiest way to get started is to use Cloud Launcher ASP.NET Framework to deploy Windows Server 2012, Microsoft IIS, ASP.NET, and SQL Express on a Compute Engine instance.

Once the ASP.NET stack is installed, ASP.NET apps can be deployed from Visual Studio using the regular Web Deployer (no special plugin needed) to your Compute Engine instance.

.NET on Google Cloud Platform page includes a Hello World with .NET sample on details on how to deploy .NET apps on Google Cloud. There is also a How to get your ASP.NET app up on Google Cloud the easy way post on Google Cloud Platform blog that you might find useful.

.NET Library for Google Cloud Platform

Once you have your basic ASP.NET app running, you probably want to know what .NET APIs and libraries exist for which part of Google Cloud Platform. 

Currently, there are 2 different .NET libraries for Google Cloud Platform: Google API Client Library for .NET and Google Cloud Platform Client Libraries for .NET. The latter libraries are currently in Alpha and Beta stages, so I won’t talk about them in detail here but stay tuned for more details in a future post.

Google API Client Library for .NET is currently the official library for many Google services, including Google Cloud Platform. It includes .NET APIs for many Google Cloud services such as Cloud Storage, BigQuery, Pub/Sub, Dataflow and more. The full list is on their APIs page (search for “cloud” for Google Cloud related APIs).

Main APIs

I want to outline some of the main .NET APIs for storing data, messaging, BigQuery and point to their NuGet packages and source code for easy reference.

Structured Data

Every application needs some kind of structured data and you have 2 options to store structured application data:

  1. Google Cloud SQL can be used with regular Entity Framework (no special API needed).
  2. Google Cloud Datastore (NoSQL) can be used with Google Cloud Datastore API Client Library for .NET (NuGet | Source).

Binary Data

You can use Google Cloud Storage to store binary data with Cloud Storage JSON API Client Library for .NET (NuGet | Source).

Messaging

You can use Google Cloud Pub/Sub for publish/subscribe messaging with Google Cloud Pub/Sub API Client Library for .NET (NuGet | Source).

BigQuery

You can work with Google Cloud BigQuery with BigQuery API Client Library for .NET (NuGet | Source).

Other APIs

For the rest of Google Cloud Platform, you can find APIs on Google Compute Engine, Google DataFlow, Google Cloud Dataproc and many more under APIs section of Google API Client Library for .NET.

Code Samples

There is also a GitHub repository called dotnet-doc-samples where more and more samples are being added for .NET on Google Cloud Platform.

As you can see, .NET is a fully supported framework and it’s only going to get better, so I’m very excited to see how .NET support will evolve going forward on Google Cloud Platform.

 

Cloud Minute: Online Resizing of Persistent Disks

Google Cloud Platform introduced online resizing of Google Cloud Persistent Disks almost a month ago. When I first read about this feature, I was so amazed that I had to try it right away.

I started with a Compute Engine instance with a persistent disk of size 100GB and doubled it to 200GB with a few clicks and resize2fs command.

Not only it worked flawlessly but it was also very quick. I documented my experience in this Cloud Minute video.

Enjoy!

Cloud Functions

In this post, I want to take a look at Cloud Functions. It’s still in Alpha but you can already play with it and I really like the idea of deploying functions without having to worry about the underlying infrastructure.

What are Cloud Functions?

In a nutshell, Cloud Functions enable you to write managed functions to respond to events in your cloud environment.

  • Managed: Cloud Functions are written in JavaScript and run on a fully managed Node.js environment on Google Cloud Platform. No need to worry about instances or infrastructure. Just deploy your function to the cloud and you’re good to go.
  • Events: Cloud Storage and Cloud Pub/Sub events or simple HTTP invocation can act as triggers to cloud functions.
  • Response: Cloud functions can respond in async (with Storage and Pub/Sub events) or sync (with HTTP invocation) fashion.

Writing Cloud Functions

  • Cloud Function are written in JavaScript as Node.js modules.
  • Each function must accept context and data as parameters and must signal completion by calling one of context.success, context.failure, and context.done methods.
  • console can be used to log error and debug messages and logs can be viewed using gcloud get-logs command.

Deploying Cloud Functions

Cloud Functions can be deployed using gcloud deploy from 2 locations:

  1. Local filesystem: You can create your function locally and use gcloud to deploy it. (One caveat is that you need to create a Cloud Storage bucket for gcloud to store your function before it can deploy it.)
  2. Cloud Source repository: You can put your function to Cloud Source repository, (A Git repository hosted on Google Cloud Platform) and deploy it from there using gcloud.

Triggering Cloud Functions

Cloud Functions can be triggered (async or sync) in 3 ways:

  1. Cloud Pub/Sub: A new message to a specific topic in Cloud Pub/Sub (async).
  2. Cloud Storage: An object created/deleted/updated in a specific bucket (async).
  3. HTTP Post: A simple HTTP Post (sync). (This requires an HTTP endpoint in Cloud Function and this endpoint is created by specifying –trigger-http flag during deployment of the function.)
    
    

Resources

Google Cloud Dataproc

DataProc_128px

Dataproc is the fourth component in Big Data section of Google Cloud Platform that I took a look and here are my short notes on Dataproc.

What is Dataproc?

  • Managed Spark, Hadoop, Hive, and Pig instances in Google Cloud.
  • It’s low cost, managed, and fast to start/scale/shutdown.
  • Integrated with the rest of Google Cloud components such as Cloud Storage, BigQuery, Bigtable.

Basics

  • You can create a Dataproc cluster and then submit jobs (Hadoop, Spark, PySpark, Hive, SparkSql, Pig) from GCP Console Dataproc section, or command line (gcloud dataproc), or via Dataproc REST API.
  • You can view job’s output from Jobs section of GCP Console Dataproc or using gcloud dataproc jobs wait.
  • You can SSH into master and other nodes in the cluster.
  • All Cloud Dataproc clusters come with the BigQuery connector for Hadoop to read/write data from BigQuery.

Resources