简体   繁体   English

多次使用 `Connect-AzAccount` 没有提示

[英]Use `Connect-AzAccount` multiple times without prompt

I'm using Connect-AzAccount in some automation scripts and it is really frustrating that every time the cmdlet is called I'm asked to authenticate, even though I authenticated very recently.我在一些自动化脚本中使用Connect-AzAccount ,每次调用 cmdlet 时都要求我进行身份验证,即使我最近进行了身份验证,这确实令人沮丧。 Is there a way to make the cmdlet search for existing context and re-use it when possible?有没有办法让 cmdlet 搜索现有上下文并在可能的情况下重新使用它? I don't want to use cert or app authentication, just reuse the existing context on my machine (without having to do so explicitly).我不想使用证书或应用程序身份验证,只需重用我机器上的现有上下文(无需明确这样做)。

If you're using Windows PowerShell and run Connect-AzAccount and are prompted to provide credentials in a window that pops up, you can run the below command to use device code flow to authenticate.如果您使用 Windows PowerShell 并运行Connect-AzAccount并提示您在弹出的 window 中提供凭据,您可以运行以下命令以使用设备代码流进行身份验证。

Connect-AzAccount -UseDeviceAuthentication

Providing this additional parameter will notify the user of the code they must use in https://microsoft.com/devicelogin to authenticate.提供此附加参数将通知用户他们必须在https://microsoft.com/devicelogin中使用的代码以进行身份验证。

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

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