azure - 使用托管标识从 Azure Runbook 运行 Get-AzADApplication

标签 azure powershell runbook

您好,我想使用自动化帐户 Runbook 获取租户内多个应用程序(但不同的订阅)的应用程序注册信息。我目前在自动化帐户上有一个系统分配的托管标识。在我的 powershell 工作流程运行手册中,我有以下代码片段:

try{
            "Logging in to Azure..."
            #Connect-AzAccount
            Connect-AzAccount -Identity
            $token = (Get-AzAccessToken -ResourceTypeName MSGraph).token
            $secreToken = ConvertTo-SecureString -String $token -AsPlainText -Force
            Connect-MgGraph -AccessToken $secreToken
            }
            catch{
                Write-Error -Message $_.Exception
                throw $_.Exception
                }


$apps = Get-AzADApplication

当我运行 Runbook 时,收到权限不足,无法完成操作。 错误消息。是否有办法以这种方式使用托管标识运行 Get-AzADApplication?如果没有,是否有更好的身份验证方法可以使用?

最佳答案

首先,我尝试了您的代码并得到了与您类似的错误,如下所示:

enter image description here

现在,首先转到azure Active Directory,然后单击角色和管理员:

enter image description here

然后搜索如下目录Readers,然后点击它:

enter image description here

然后单击“添加作业”,如下所示:

enter image description here

然后选择一个成员,如下所示:

enter image description here

然后点击下一步:

enter image description here

现在我返回 Runbook,当我运行时,错误已解决: enter image description here

关于azure - 使用托管标识从 Azure Runbook 运行 Get-AzADApplication,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75163190/

相关文章:

azure - 获取 Azure Kubernetes Pod 的线程转储/堆转储

azure - Web异常 "The remote server returned an error: (409) Conflict"

function - powershell 中的美元符号、函数关键字和脚本 block

powershell - 如何使用来自 sql 作业代理的默认凭据运行 powershell 脚本

azure - 何时使用机器人、FaaS、Runbook 和逻辑应用程序

Azure 自动化启动-AzureAutomationRunbook 错误

azure - Pyspark Azure Blob 存储 - 未找到类 org.apache.hadoop.fs.azure.NativeAzureFileSystem

php - 具有与 SQL Server 的 Laravel 连接的 Azure Web 应用程序

powershell - 无法获取文件掩码以在PowerShell中的多行WinSCP命令行中正常工作

azure - Runbook 作为 azure 帐户运行 Powershell