A collection of samples that demonstrate how to call some Google Cloud services from C#.
The APIs and .NET Libraries page lists all the Cloud APIs you can call from .NET.
The samples in this repo cover only some of the total APIs that you can call from .NET.
Windows | Linux |
---|---|
To build and run a sample, open the solution file (.sln) with Visual Studio 2015 or later and build it.
But no sample will work until you:
-
Create a project in the Google Cloud Platform Console. If you haven't already created a project, create one now. Projects enable you to manage all Google Cloud Platform resources for your app, including deployment, access control, billing, and services.
- Open the Cloud Platform Console.
- In the drop-down menu at the top, select Create a project.
- Click Show advanced options. Under App Engine location, select a United States location.
- Give your project a name.
- Make a note of the project ID, which might be different from the project name. The project ID is used in commands and in configurations.
- In each sample directory, a README.md contains additional steps necessary to run the sample. Don't forget to follow those instructions too.
-
Enable billing for your project. If you haven't already enabled billing for your project, enable billing now. Enabling billing allows the application to consume billable resources such as running instances and storing data.
-
Download credentials.
-
Visit the APIs & services dashboard and click Credentials.
-
Click Create credentials and choose Service Account key.
-
Under Service account, choose Compute Engine default service account, and leave JSON selected under Key Type. Click Create. A .json file will be downloaded to your computer.
-
Set the environment variable
GOOGLE_APPLICATION_CREDENTIALS
to the path of the JSON key that was downloaded. In powershell, the command will like something like this:# For this powershell session. PS > $env:GOOGLE_APPLICATION_CREDENTIALS = "$env:USERPROFILE\Downloads\your-project-id-dea9fa230eae3.json" # For all processes created after this command. PS > [Environment]::SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "$env:USERPROFILE\Downloads\your-project-id-dea9fa230eae3.json", "User")
-
-
Enable APIs. Visit the APIs & services dashboard and click ENABLE API. Enable the APIs you plan to call. Are you going to use Cloud Datastore? Enable the Cloud Datastore API. Each API must be enabled individually.
-
Download or clone this repo with
git clone https://github.com/GoogleCloudPlatform/dotnet-docs-samples
Browse the directories, find a solution (.sln) file, open it with Visual Studio 2015 or later, and run it!
- See CONTRIBUTING.md
- See LICENSE
- See TESTING.md