Install a development environment
Create a Google Cloud project
Create a Google Cloud project to run your apps. Google Cloud projects form the basis for creating, enabling, and using all Google Cloud services.
During local development, your .NET app must authenticate itself in order to interact with Google Cloud APIs. The following instructions describe how to create a service account key to authenticate your app. Apps can use this method to authenticate locally and when deployed to Google Cloud. Read more about authentication, including how authentication is handled once your app is deployed.
Create a service account key for authentication
In the Cloud Console, go to the Create service account key page.Go to the Create Service Account Key page
- From the Service account list, select New service account.
- In the Service account name field, enter a name.
From the Role list, select Project > Owner.Note: The Role field authorizes your service account to access resources. You can view and change this field later by using the Cloud Console. If you are developing a production app, specify more granular permissions than Project > Owner. For more information, see granting roles to service accounts.
- Click Create. A JSON file that contains your key downloads to your computer.
Create the service account. Replace [NAME] with a name for the service account.
gcloud iam service-accounts create [NAME]
Grant permissions to the service account. Replace [PROJECT_ID] with your project ID.
gcloud projects add-iam-policy-binding [PROJECT_ID] --member "serviceAccount:[NAME]@[PROJECT_ID].iam.gserviceaccount.com" --role "roles/owner"
Generate the key file. Replace [FILE_NAME] with a name for the key file.
gcloud iam service-accounts keys create [FILE_NAME].json --iam-account [NAME]@[PROJECT_ID].iam.gserviceaccount.com
Next, set the environment variable
to the path of the JSON key that was downloaded. In PowerShell,
the commands are:
For this PowerShell session.
$env:GOOGLE_APPLICATION_CREDENTIALS = "$env:USERPROFILE\Downloads\your-project-id-dea9fa230eae3.json"
For all processes created after this command.
[Environment]::SetEnvironmentVariable("GOOGLE_APPLICATION_CREDENTIALS", "$env:USERPROFILE\Downloads\your-project-id-dea9fa230eae3.json", "User")
(Optional) Install .NET tools and SDKs
Even though you can create and manage Google Cloud resources via your web browser using the Google Cloud Console, if you'd prefer to manage your Google Cloud resources from within Visual Studio or from the command-line, you can consider installing the following tools:
Cloud SDK: The Cloud SDK is a command-line interface for Google Cloud products and services.
Tools for Visual Studio: Tools for Visual Studio enables development in Visual Studio on Google Cloud.
Tools for PowerShell: Tools for PowerShell is a set of cmdlets for Windows PowerShell that lets you manage Google Cloud resources.