本教程介绍了如何为 .NET 和 .NET Framework 应用的开发准备本地机器,这些应用在 Google Cloud 上运行并调用 Google Cloud API。
安装开发环境
在本文档中,用于运行 .NET 教程和示例应用的推荐开发环境是 Visual Studio 或 Visual Studio Code。
创建 Google Cloud 项目
创建 Google Cloud 项目以运行您的应用。 Google Cloud 项目是创建、启用和使用所有 Google Cloud 服务的基础。
设置身份验证
您的 .NET 应用必须进行自身身份验证,才能使用 Google Cloud API。您可以使用应用默认凭据 (ADC),以便为本地开发或生产环境提供凭据。
If you're using a local shell, then create local authentication credentials for your user account:
gcloud auth application-default login
You don't need to do this if you're using Cloud Shell.
If an authentication error is returned, and you are using an external identity provider (IdP), confirm that you have signed in to the gcloud CLI with your federated identity.
如需了解详情,请参阅使用客户端库时进行身份验证。如需了解有关身份验证的一般信息,请参阅在 Google 进行身份验证。
(可选)安装 .NET 工具和 SDK
您可以通过网络浏览器使用 Google Cloud 控制台来创建和管理 Google Cloud 资源,不过,如果您希望通过 Visual Studio 或命令行来管理 Google Cloud 资源,也可以考虑安装以下工具:
Google Cloud CLI:gcloud CLI 是 Google Cloud产品和服务的命令行界面。
Tools for Visual Studio:Tools for Visual Studio 可在 Google Cloud上的 Visual Studio 中进行开发。