.NET EN GOOGLE CLOUD PLATFORM

Pruébalo gratis Ver la documentación

Compila, implementa, depura y supervisa apps de .NET altamente escalables

  • check Compila apps de .NET con Visual Studio, línea de comandos basada en navegador o Windows PowerShell
  • check Usa los servicios de GCP mediante bibliotecas idiomáticas de .NET
  • check Consulta una base de datos de SQL completamente administrada con C#
  • check Escala las apps de .NET Core con la tecnología de Google
  • check Inicia Windows Servers preconfigurados para ASP.NET
  • check Implementa apps de ASP.NET Core como contenedor de Docker
Conjunto amplio de bibliotecas idiomáticas de .NET

Aprovecha las bibliotecas populares en C# para acceder a los servicios de Google Cloud Platform

Almacena y archiva datos en Cloud Storage
Accede a bases de datos NoSQL completamente administradas mediante C#
Realiza análisis de datos con BigQuery
Traduce texto en diferentes idiomas con la API de Translation
Analiza imágenes con la API de Vision
Almacena y archiva datos en Cloud Storage
1
Instala la biblioteca cliente con el administrador de paquetes NuGet, o la CLI de .NET o de Paket
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
Configura un proyecto de Cloud Platform Console
  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
Escribe el código
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);
            }
        }
    }
}
Accede a bases de datos de NoSQL completamente administradas mediante C#
1
Instala la biblioteca cliente con el administrador de paquetes NuGet, o la CLI de .NET o de Paket
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
Configura un proyecto de Cloud Platform Console
  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
Escribe el código
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"]}");
            }
        }
    }
}
Realiza análisis de datos con BigQuery
1
Instala la biblioteca cliente con el administrador de paquetes NuGet, o la CLI de .NET o de Paket
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
Configura un proyecto de Cloud Platform Console
  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
Escribe el código
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();
        }
    }
}
Traduce texto en diferentes idiomas con la API de Translation
1
Instala la biblioteca cliente con el administrador de paquetes NuGet, o la CLI de .NET o de Paket
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
Configura un proyecto de Cloud Platform Console
  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
Escribe el código
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);
    }
}
Analiza imágenes con la API de Vision
1
Instala la biblioteca cliente con el administrador de paquetes NuGet, o la CLI de .NET o de Paket
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
Configura un proyecto de Cloud Platform Console
  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
Escribe el código
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);
            }
        }
    }
}
GUÍAS DE INICIO RÁPIDO DE .NET
Descubre y soluciona problemas de producción

Stackdriver proporciona funcionalidades potentes de registro, supervisión y generación de informes. Te brinda estadísticas sobre el estado, el rendimiento y la disponibilidad de las aplicaciones en la nube, lo que te permite detectar y solucionar problemas más rápido.

Más información
.NET EN LAS COMUNIDADES DE GCP

¿Tienes algo que decir? Únete a nuestra comunidad para hacer preguntas o chatear con los expertos de Google encargados de la asistencia de .NET en Google Cloud Platform.