Uiterst schaalbare .NET-apps ontwerpen, implementeren, repareren en controleren

  • check Ontwerp .NET-apps met Visual Studio, opdrachtregels op basis van de browser of Windows PowerShell
  • check Gebruik GCP-services via idiomatische .NET-bibliotheken
  • check Doorzoek volledig beheerde SQL-databases met C#
  • check Schaal .NET Core-apps met de technologie van Google
  • check Start vooraf geconfigureerde ASP.NET Windows Servers
  • check Implementeer ASP.NET Core-apps als Docker-container
Een breed scala aan originele .NET-bibliotheken

Gebruik populaire bibliotheken in C# voor toegang tot Google Cloud Platform-services

Gegevensopslag en -archivering binnen Cloud Storage
Toegang tot volledig beheerde NoSQL-database met C#
Gegevensanalyse uitvoeren met BigQuery
Tekst vertalen naar verschillende talen met de Translation API
Afbeeldingen analyseren met de Vision API
Gegevensopslag en -archivering binnen Cloud Storage
1
Installeer de clientbibliotheek met NuGet Package Manager, .NET CLI of Paket CLI
PM> Install-Package Google.Cloud.Storage.V1 -Version 2.1.0-beta01
.NET CLI> dotnet add package Google.Cloud.Storage.V1 --version 2.1.0-beta01
Paket CLI> paket add Google.Cloud.Storage.V1 --version 2.1.0-beta01
2
Stel een Cloud Platform Console-project in
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the Cloud Storage API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Schrijf uw code
using Google.Cloud.Storage.V1;
using System;
using System.Diagnostics;

namespace GoogleCloudSamples
{
    class StorageQuickstart
    {
        static void Main(string[] args)
        {
            // Your Google Cloud Platform project ID.
            string projectId = "YOUR-PROJECT-ID";

            // Instantiates a client.
            StorageClient storageClient = StorageClient.Create();

            // The name for the new bucket.
            string bucketName = projectId + "-test-bucket";
            try
            {
                // Creates the new bucket.
                storageClient.CreateBucket(projectId, bucketName);
                Console.WriteLine($"Bucket {bucketName} created.");
            }
            catch (Google.GoogleApiException e)
            when (e.Error.Code == 409)
            {
                // The bucket already exists.  That's fine.
                Console.WriteLine(e.Error.Message);
            }
        }
    }
}
Toegang tot volledig beheerde NoSQL-database met C#
1
Installeer de clientbibliotheek met NuGet Package Manager, .NET CLI of Paket CLI
PM> Install-Package Google.Cloud.Datastore.V1 -Version 2.0.0
.NET CLI> dotnet add package Google.Cloud.Datastore.V1 --version 2.0.0
Paket CLI> paket add Google.Cloud.Datastore.V1 --version 2.0.0
2
Stel een Cloud Platform Console-project in
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the Cloud Datastore API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Schrijf uw code
using Google.Cloud.Datastore.V1;

namespace GoogleCloudSamples
{
    public class QuickStart
    {
        public static void Main(string[] args)
        {
            // Your Google Cloud Platform project ID
            string projectId = "YOUR-PROJECT-ID";

            // Instantiates a client
            DatastoreDb db = DatastoreDb.Create(projectId);

            // The kind for the new entity
            string kind = "Task";
            // The name/ID for the new entity
            string name = "sampletask1";
            KeyFactory keyFactory = db.CreateKeyFactory(kind);
            // The Cloud Datastore key for the new entity
            Key key = keyFactory.CreateKey(name);

            var task = new Entity
            {
                Key = key,
                ["description"] = "Buy milk"
            };
            using (DatastoreTransaction transaction = db.BeginTransaction())
            {
                // Saves the task
                transaction.Upsert(task);
                transaction.Commit();

                Console.WriteLine($"Saved {task.Key.Path[0].Name}: {(string)task["description"]}");
            }
        }
    }
}
Gegevensanalyse uitvoeren met BigQuery
1
Installeer de clientbibliotheek met NuGet Package Manager, .NET CLI of Paket CLI
PM> Install-Package Google.Cloud.BigQuery.V2 -Version 1.0.0-beta19
.NET CLI> dotnet add package Google.Cloud.BigQuery.V2 --version 1.0.0-beta19
Paket CLI> paket add Google.Cloud.BigQuery.V2 --version 1.0.0-beta19
2
Stel een Cloud Platform Console-project in
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the BigQuery API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Schrijf uw code
using System;
using Google.Cloud.BigQuery.V2;

namespace GoogleCloudSamples
{
    public class BigquerySample
    {
        const string usage = @"Usage:
BigquerySample <project_id>";

        private static void Main(string[] args)
        {
            string projectId = null;
            if (args.Length == 0)
            {
                Console.WriteLine(usage);
            }
            else
            {
                projectId = args[0];
                // By default, the Google.Cloud.BigQuery.V2 library client will authenticate
                // using the service account file (created in the Google Developers
                // Console) specified by the GOOGLE_APPLICATION_CREDENTIALS
                // environment variable. If you are running on
                // a Google Compute Engine VM, authentication is completely
                // automatic.
                var client = BigQueryClient.Create(projectId);
                string query = @"SELECT
                    CONCAT(
                        'https://stackoverflow.com/questions/',
                        CAST(id as STRING)) as url, view_count
                    FROM `bigquery-public-data.stackoverflow.posts_questions`
                    WHERE tags like '%google-bigquery%'
                    ORDER BY view_count DESC
                    LIMIT 10";
                var result = client.ExecuteQuery(query, parameters: null);
                Console.Write("\nQuery Results:\n------------\n");
                foreach (var row in result)
                {
                    Console.WriteLine($"{row["url"]}: {row["view_count"]} views");
                }
            }
            Console.WriteLine("\nPress any key...");
            Console.ReadKey();
        }
    }
}
Tekst vertalen naar verschillende talen met de Translation API
1
Installeer de clientbibliotheek met NuGet Package Manager, .NET CLI of Paket CLI
PM>Install-Package Google.Cloud.Translation.V2 -Version 1.0.0
.NET CLI> dotnet add package Google.Cloud.Translation.V2 --version 1.0.0
Paket CLI> paket add Google.Cloud.Translation.V2 --version 1.0.0
2
Stel een Cloud Platform Console-project in
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the Cloud Translation API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Schrijf uw code
using Google.Cloud.Translation.V2;
using System;

public class QuickStart
{
    public static void Main(string[] args)
    {
        Console.OutputEncoding = System.Text.Encoding.Unicode;
        TranslationClient client = TranslationClient.Create();
        var response = client.TranslateText("Hello World.", "ru");
        Console.WriteLine(response.TranslatedText);
    }
}
Afbeeldingen analyseren met de Vision API
1
Installeer de clientbibliotheek met NuGet Package Manager, .NET CLI of Paket CLI
PM> Install-Package Google.Cloud.Vision.V1 -Version 1.0.0
.NET CLI> dotnet add package Google.Cloud.Vision.V1 --version 1.0.0
Paket CLI> paket add Google.Cloud.Vision.V1 --version 1.0.0
2
Stel een Cloud Platform Console-project in
  1. Sign in to your Google Account.

    If you don't already have one, sign up for a new account.

  2. Set up a GCP Console project.

    Set up a project

    Click to:

    • Create or select a project.
    • Enable the Cloud Vision API for that project.
    • Create a service account.
    • Download a private key as JSON.

    You can view and manage these resources at any time in the GCP Console.

3
Schrijf uw code
using Google.Cloud.Vision.V1;
using System;

namespace GoogleCloudSamples
{
    public class QuickStart
    {
        public static void Main(string[] args)
        {
            // Instantiates a client
            var client = ImageAnnotatorClient.Create();
            // Load the image file into memory
            var image = Image.FromFile("wakeupcat.jpg");
            // Performs label detection on the image file
            var response = client.DetectLabels(image);
            foreach (var annotation in response)
            {
                if (annotation.Description != null)
                    Console.WriteLine(annotation.Description);
            }
        }
    }
}
KORTE TRAININGEN VOOR .NET
Productieproblemen opsporen en oplossen

Google Stackdriver biedt krachtige mogelijkheden voor logboekregistratie, controle en rapportage. Deze tool geeft inzicht in de status, prestaties en beschikbaarheid van cloud-apps en stelt u in staat om problemen in productie sneller op te sporen en op te lossen.

Meer informatie
.NET OP GCP-COMMUNITY'S

Wilt u meepraten? Word lid van onze community om vragen te stellen, of chat met de Google-experts die werken aan .NET-ondersteuning op Google Cloud Platform.