简体   繁体   English

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

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

I have a C# application which needs access to Azure to run, While running locally I do "az login" first and run the application.我有一个 C# 应用程序需要访问 Azure 才能运行,在本地运行时我先执行“az 登录”并运行该应用程序。 But while running the same application as windows service this doesn't work even thought I do "az login" before running the service.但是,在运行与 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)

This is the error I get in Event listener.这是我在事件侦听器中遇到的错误。

So is there any way to login to azure while running application as windows service.那么有什么方法可以在将应用程序作为 windows 服务运行时登录到 azure。

System.AggregateException: Multiple exceptions were encountered while attempting to authenticate. System.AggregateException:尝试进行身份验证时遇到多个异常。 (EnvironmentCredential authentication unavailable. Environment variables are not fully configured. The requested identity has not been assigned to this resource. (EnvironmentCredential 身份验证不可用。环境变量未完全配置。请求的身份尚未分配给此资源。
Status: 400 (Bad Request)状态:400(错误请求)

As mentioned in this GitHub Article of Troubleshooting EnvironmentCredential authentication issues Section, the mitigation is you need to create the app registration with your app service (windows service) deployed in Azure and login to the Azure before running the service with the cmdlet that contains service principal given in this MS Doc of Azure CLI Login with Service Principal.如这篇 GitHub EnvironmentCredential凭据身份验证问题疑难解答文章部分所述,缓解措施是您需要使用部署在 Azure 中的应用程序服务(Windows 服务)创建应用程序注册,并在使用包含服务主体的 cmdlet 运行该服务之前登录到 Azure在此 Azure CLI 使用服务主体登录的MS 文档中给出。

Stored credentials not found.未找到存储的凭据。 Need to authenticate user in VSCode Azure Account.需要在 VSCode Azure 帐户中对用户进行身份验证。

For this issue, when you're logged in to Azure in the VS Code, make sure all the settings are syncing.对于此问题,当您在 VS Code 中登录 Azure 时,请确保所有设置都已同步。 Sync should be turn on from VS Code IDE as shown in the below screenshot:应该从 VS Code IDE 打开同步,如下面的屏幕截图所示:

在此处输入图像描述

Try Signing in with Command Palette (Ctrl + Shift + P) > Sign in to the Azure > and then Turn on the Settings Sync from the VS Code Accounts Option.尝试使用命令面板登录 (Ctrl + Shift + P) > 登录到 Azure > 然后从 VS 代码帐户选项打开设置同步。

I was trying to make Windows service on Azure windows VM.我试图在 Azure windows 虚拟机上提供 Windows 服务。

I was able to login to azure in service by doing this.通过这样做,我能够登录到服务中的 azure。

在此处输入图像描述

At first it was log on as local system account.起初它是以本地系统帐户登录的。

I changed it to This account and provided with My Bastion credentials for VM.我将其更改为此帐户并提供了 VM 的 My Bastion 凭据。

Then the service was able to login to azure successfully.然后该服务能够成功登录azure。

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

相关问题 我如何知道我的 Azure 应用服务正在运行的 IIS 和 Windows 是什么版本 - How do I tell what version of IIS and Windows my Azure App Service is running on 使用 gcloud 服务帐号登录 firebase - Login to firebase using gcloud service account 如何使用应用程序 ID(服务主体)的令牌向 Azure Devops 进行身份验证? - How to authenticate to Azure Devops by using token of an Application ID(service principal)? 如何下载服务帐号Json? - How to download a Service Account Json? 服务帐户模拟如何工作? - How Service Account impersonation works? windows azure 开发存储 blob 服务未启动 - windows azure development storage blob service not starting 运行 Firebase Cloud Functions 时使用哪个服务帐户? - Which service account is used when running Firebase Cloud Functions? 无法在运行 Windows 的 Azure VM 上配置 Azure Insights - Unable to configure Azure Insights on Azure VM running Windows 托管服务帐户在添加 ObjectAccessControl 时没有足够的权限 - Managed Service Account does not have enough permissions while adding ObjectAcessControl 在 GCP 上通过 Firestore 使用应用程序默认凭据/服务帐户 - Using Application Default Credentials / Service Account with Firestore on GCP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM