为什么我的 Gmail user/password 在将 ASP.NET 部署到 Visual Studio 中的 Compute Engine 时无法正常工作?

Why doesn't my Gmail user/password work when deploying ASP.NET to Compute Engine inside Visual Studio?

我使用 ASP.NET Cloud Launcher 创建了一个 Compute Engine VM,现在我想从 Visual Studio.

部署到它

我使用 Visual Studio 扩展创建了一个发布设置文件,然后尝试使用常规 Visual Studio "Publish" 命令进行部署。这些设置不包含用户名和密码,所以我使用了我的 Gmail/Google 凭据 - 这是我的帐户有权访问的计算引擎实例,毕竟:

失败并出现以下错误:

Web deployment task failed. (Connected to the remote computer ("(redacted)") using the Web Management Service, but could not authorize. Make sure that you are using the correct user name and password, that the site you are connecting to exists, and that the credentials represent a user who has permissions to access the site. Learn more at: http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_USER_UNAUTHORIZED.)

如果这不是要使用的用户名和密码,那是什么?

Compute Engine 实例根本不知道您的 Google 用户 - 它只知道常规 Windows 帐户,而您没有 Windows 帐户它。因此,您需要在实例上创建一个 Windows 帐户,然后将其放入发布设置中。

在 Google Cloud Explorer 中,select 实例并选择 "Create or Reset Password":

然后您可以选择您喜欢的任何用户名 - 例如,为了简单起见,我建议使用 "aspnet"。请注意,此用户名是计算机上的普通 Windows 帐户 - 它不是特定于您的 Google 用户。如果您与其他人共享这台机器进行开发,您应该就一组帐户名称达成一致,或者安全地共享单个帐户的凭据,或者为每个开发人员创建一个单独的帐户。您不想为同事正在使用的帐户重置密码!

此帐户还可用于打开与 Compute Engine 实例的终端服务器会话。

等到用密码创建用户,然后复制密码:

您现在可以将其放入您的发布设置并让 Visual Studio 保存密码 - 当然,如果您愿意,还可以在单​​独的安全位置保留一份副本。