.NET Bookshelf App

The Bookshelf app is a sample web app written in .NET that shows how to use a variety of Google Cloud Platform products, including:

  • Google App Engine flexible environment
  • Google Cloud SQL
  • Google Cloud Datastore
  • Google Cloud Storage
  • Google Cloud Pub/Sub
  • Google Compute Engine

This tutorial explores the Bookshelf app in detail, and discusses how each feature of the app is implemented using familiar technologies and services provided by Cloud Platform.

Screen shot of the Bookshelf app showing controls and book covers

The Bookshelf sample app stores a collection of book titles. Anyone who has access to the app can add books to the list. The sample app offers these features:

  • Users can view the list of books, add books to the list, and remove books from the list.
  • Users can edit book details.
  • Users can upload cover images for books.

Objectives

  • Clone or download the sample app.
  • Build the app and run it on your local machine.
  • Deploy the app to App Engine.
  • Walk through the sample code.
  • Learn how the app stores structured data.
  • Learn how the app stores binary data in Google Cloud Storage.
  • Learn how the app uses Google Cloud Pub/Sub to send tasks to a background worker.

Costs

This tutorial uses billable components of Cloud Platform including Google Compute Engine.

New Cloud Platform users might be eligible for a free trial.

This tutorial has several steps, and each step is documented on its own page. The final page of the tutorial includes instructions for cleaning up resources, so you won't continue to be billed for Cloud Platform services. If you decide not to complete all the steps of the tutorial, see the cleanup instructions on the final page.

Before you begin

  1. Use the Cloud Platform Console to set up your Google Cloud Platform project:
    1. Create a new Cloud Platform project, and then create an App Engine application and enable billing in that project:
      Go to App Engine

      When prompted, select the region where you want your App Engine application located and then enable billing. After your Cloud Platform project is created, the Dashboard opens.

    2. Enable the Cloud Datastore, Cloud Pub/Sub, Cloud Storage JSON, Stackdriver Logging, and Google+ APIs.

      Enable the APIs

  2. Download, install, and initialize the Google Cloud SDK:
    Download the SDK
  3. Acquire local credentials for authenticating with Google Cloud Platform services:
    gcloud auth application-default login
  4. Verify that your default project is correct:
    gcloud config list
    If the project ID listed in the output is not the project that you intended to use for this tutorial, set the project by entering this command:
    gcloud config set project [YOUR_PROJECT_ID]
    where [YOUR_PROJECT_ID] is the ID of the project you created or chose to use for this tutorial.
  5. Clone the sample repository:

    git clone https://github.com/GoogleCloudPlatform/getting-started-dotnet.git

    Alternatively, you can download the sample as a zip file and extract it.

This tutorial assumes that you have Visual Studio 2013 or later installed and are familiar with the .NET Framework and the C# language.

Creating a Compute Engine instance

Use the Google Cloud Launcher to create a new Compute Engine instance that has Windows Server 2012 R2, Microsoft IIS, ASP.NET, and SQL Express preinstalled:

  1. In the Cloud Platform Console, go to the Cloud Launcher ASP.NET Framework page.

  2. Set your deployment name to bookshelf-tutorial.

  3. Choose a Compute Engine zone.

  4. Click Deploy to deploy the instance.

After the deployment process finishes, add a default Windows user to your new instance:

  1. In the Cloud Platform Console, go to the VM instances page.

  2. Click the name of your newly deployed instance, bookshelf-tutorial.

  3. On the instance page, click Create or reset Windows password.

  4. In the Set new Windows password dialog, add your username, and click Set to create the user account on your instance.

  5. Make a note of the provided password, and close the dialog.

Tutorial structure

The Bookshelf tutorial has several parts that demonstrate how the sample app uses various Cloud Platform services.

The structured data part of the tutorial demonstrates how the sample app stores book information in a SQL or NoSQL database. The app's web page displays a form where the user can enter the title, author, description, and publication date of a book. For each book entered, the app stores this information in a database, so it can be retrieved later for viewing or editing. For this step of the tutorial, you have your choice of three databases: Cloud SQL, Cloud Datastore, or SQL Server. After you complete this step with one of the databases, you can move on to the next step.

The Cloud Storage part of the tutorial demonstrates how the sample app stores binary data in Cloud Storage. On the app's web page, the user can specify a cover image for each book. The app stores the cover images in a Cloud Storage bucket.

The Pub/Sub part of the tutorial demonstrates how the app uses Cloud Pub/Sub to send tasks to a background worker. The worker gathers information from the Google Books API and updates the book information in the database.

Monitor your resources on the go

Get the Google Cloud Console app to help you manage your projects.

Send feedback about...