繁体   English   中英

如何在运行应用程序作为 windows 服务时登录到 azure 帐户?

[英]How to login to azure account while running the application as windows service?

我有一个 C# 应用程序需要访问 Azure 才能运行,在本地运行时我先执行“az 登录”并运行该应用程序。 但是,在运行与 windows 服务相同的应用程序时,即使我在运行该服务之前执行“az 登录”,这也不起作用。


- Visual Studio Token provider can't be accessed at C:\Windows\system32\config\systemprofile\AppData\Local\.IdentityService\AzureServiceAuth\tokenprovider.json
- Stored credentials not found. Need to authenticate user in VSCode Azure Account. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/vscodecredential/troubleshoot
- Please run 'az login' to set up account
- PowerShell is not installed.
 ---> System.AggregateException: Multiple exceptions were encountered while attempting to authenticate. (EnvironmentCredential authentication unavailable. Environment variables are not fully configured. See the troubleshooting guide for more information. https://aka.ms/azsdk/net/identity/environmentcredential/troubleshoot) (ManagedIdentityCredential authentication unavailable. The requested identity has not been assigned to this resource.
Status: 400 (Bad Request)

这是我在事件侦听器中遇到的错误。

那么有什么方法可以在将应用程序作为 windows 服务运行时登录到 azure。

System.AggregateException:尝试进行身份验证时遇到多个异常。 (EnvironmentCredential 身份验证不可用。环境变量未完全配置。请求的身份尚未分配给此资源。
状态:400(错误请求)

如这篇 GitHub EnvironmentCredential凭据身份验证问题疑难解答文章部分所述,缓解措施是您需要使用部署在 Azure 中的应用程序服务(Windows 服务)创建应用程序注册,并在使用包含服务主体的 cmdlet 运行该服务之前登录到 Azure在此 Azure CLI 使用服务主体登录的MS 文档中给出。

未找到存储的凭据。 需要在 VSCode Azure 帐户中对用户进行身份验证。

对于此问题,当您在 VS Code 中登录 Azure 时,请确保所有设置都已同步。 应该从 VS Code IDE 打开同步,如下面的屏幕截图所示:

在此处输入图像描述

尝试使用命令面板登录 (Ctrl + Shift + P) > 登录到 Azure > 然后从 VS 代码帐户选项打开设置同步。

我试图在 Azure windows 虚拟机上提供 Windows 服务。

通过这样做,我能够登录到服务中的 azure。

在此处输入图像描述

起初它是以本地系统帐户登录的。

我将其更改为此帐户并提供了 VM 的 My Bastion 凭据。

然后该服务能够成功登录azure。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM