- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 VSTS 项目,通过服务主体通过 Azure 资源管理器终结点连接到 Azure 订阅。这对于我通过模板化、参数驱动的部署配置 ARM 资源的构建来说效果很好。
我还有一个额外要求,即在构建过程中设置 Azure AD 组。我有一个可以在本地计算机上正常运行的脚本。当我通过构建部署它并在托管构建 Controller 上执行时,脚本最初找不到 AzureAD 模块。我通过将脚本包含在 git Repo 中并通过以下方式访问它来解决这个问题:
$adModulePath = $PSScriptRoot + "\PsModules\AzureAD\2.0.0.131\AzureAD.psd1"
Import-Module $adModulePath
但是,我现在在运行 New-AzureADGroup
时遇到了另一个问题。该脚本要求在发出命令之前运行 Connect-AzureAD
。通过对凭据进行硬编码可以很好地工作,但我不想这样做,我希望它在创建的 SPN 的上下文中运行,该 SPN 在托管构建 Controller 上运行脚本。
因此,问题是,我能否获取 Azure PowerShell 执行 SPN 的当前上下文并将其传递给 Connect-AzureAD
以避免以纯文本形式存储凭据?我错过了一个技巧吗?还有其他选择吗?
我当前的代码如下,注释连接在命令中工作正常,就像硬编码值一样。不带参数的调用会显示登录 UI,该 UI 会终止构建,因为它显然不是交互式的。
## Login to Azure
#$SecurePassword = ConvertTo-SecureString $AdminPassword -AsPlainText -Force
#$AdminCredential = New-Object System.Management.Automation.PSCredential ($AdminUserEmailAddress, $SecurePassword)
#Connect-AzureAD -Credential $AdminCredential
Connect-AzureAD
Write-Output "------------------ Start: Group Creation ------------------"
$TestForAdminGroup = Get-AzureADGroup -SearchString $AdminGroup
$TestForContributorGroup = Get-AzureADGroup -SearchString $ContributorGroup
$TestForReaderGroup = Get-AzureADGroup -SearchString $ReaderGroup
谢谢
最佳答案
这是可能的。今天为我自己工作了VSTS extension我不久前发布的。我的扩展使用 Azure 资源管理器端点
作为输入。
现在使用以下代码在 Microsoft 托管的 Visual Studio 2017 代理池上运行它。更多信息请参阅我的post on how to use AzureAD PowerShell cmdlets on VSTS agent .
Write-Verbose "Import AzureAD module because is not on default VSTS agent"
$azureAdModulePath = $PSScriptRoot + "\AzureAD\2.0.1.16\AzureAD.psd1"
Import-Module $azureAdModulePath
# Workaround to use AzureAD in this task. Get an access token and call Connect-AzureAD
$serviceNameInput = Get-VstsInput -Name ConnectedServiceNameSelector -Require
$serviceName = Get-VstsInput -Name $serviceNameInput -Require
$endPointRM = Get-VstsEndpoint -Name $serviceName -Require
$clientId = $endPointRM.Auth.Parameters.ServicePrincipalId
$clientSecret = $endPointRM.Auth.Parameters.ServicePrincipalKey
$tenantId = $endPointRM.Auth.Parameters.TenantId
$adTokenUrl = "https://login.microsoftonline.com/$tenantId/oauth2/token"
$resource = "https://graph.windows.net/"
$body = @{
grant_type = "client_credentials"
client_id = $clientId
client_secret = $clientSecret
resource = $resource
}
$response = Invoke-RestMethod -Method 'Post' -Uri $adTokenUrl -ContentType "application/x-www-form-urlencoded" -Body $body
$token = $response.access_token
Write-Verbose "Login to AzureAD with same application as endpoint"
Connect-AzureAD -AadAccessToken $token -AccountId $clientId -TenantId $tenantId
关于powershell - VSTS 构建和 PowerShell 以及 AzureAD 身份验证,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46554136/
我已在 Powershell 版本 7 中安装了 AzureAD 模块,但无法执行 Connect-AzureAD Cmdlet。 有什么想法吗? PS C:\Users\User> Get-Inst
我有一个 WebApplication(例如 https://test.com/webapp1 处的 WebApp1)。 WebApp1 要求用户使用 AzureAD 进行身份验证(TenantId:
我正在尝试在 ADO 中的 azure powershell 任务中执行 Get-AzureADServicePrincipal。我需要获取服务主体,然后连接以获取 ServicePrincipalI
我正在尝试在 ADO 中的 azure powershell 任务中执行 Get-AzureADServicePrincipal。我需要获取服务主体,然后连接以获取 ServicePrincipalI
我想使用 Azuread Provider 创建应用程序注册,并使用 applictionid 输出作为我的应用程序服务中的配置。每次我计划时,我都会收到一条错误消息。如果我删除配置行,一切正常。 我
我正在尝试 AzureAD 试用版,以便使用 Microsoft 产品提供的 API(我也注册了高级试用版)。 我已成功注册我的 iOS 应用程序,但每当我尝试添加权限时,它都会在“选择权限”处显示雨
我已经在门户中设置了我的 AzureAD,以及一个使用 AD 来验证以下 Microsoft 说明的应用程序服务。 我制作了一个使用此授权的 .net core 应用程序。它可以在我的本地主机上运行。
我已经在门户中设置了我的 AzureAD,以及一个使用 AD 来验证以下 Microsoft 说明的应用程序服务。 我制作了一个使用此授权的 .net core 应用程序。它可以在我的本地主机上运行。
我正在开发一个管道,用于从 Azure Active Directory 检索所有条件访问策略并创建 csv 列表 我的问题是,我发现一个命令 get-azureadmsconditionalacce
RestAPI:我有一个使用 AzureAd 身份验证运行 Asp Core 的 Rest API。 WebApp:我有一个单独的 Web 应用程序,运行 Asp Core 作为后端,并使用 Java
我正在尝试使此命令在我的 MAC 操作系统上运行,甚至安装我在其他博客中找到的所有模块,例如 AzureAD、AzureADPreview。我仍然收到同样的消息。有人可以给我一些有关修复的线索吗? C
尝试通过 powershell 将一些 Azure AD 组从静态更改为动态(有 75 个组,因此我们需要以某种方式执行此操作) 最初我试图使用此脚本从 TXT 中的列表自动运行它: $groupli
我们正在使用MS Graph API,想检查某个组中用户的变化。目前我们通过以下查询获取用户: https://graph.microsoft.com/v1.0/groups/group-id/mem
我正在运行脚本以将新用户添加到 Azure AD $AzureADConnection = Connect-AzureAD $AdminEmail = $AzureADConnection.Accou
我尝试使用命令 Connect-AzureAD 通过 PowerShell 连接到 AzureAD,但单点登录时出现空白页面。 但是,当我使用命令 Connect-MsolService 时,它就像一
我们在自己的服务器上有应与 SharePoint Online 一起使用的应用程序。要访问 SP Online,我们需要拥有应用 token / secret - 这很好。 我想知道是否有可能通过此
我有一些公司网站提供一些受 Azure AD 保护的信息。这在浏览器中工作得很好,但我想在命令行上创建一些自动化。 如果我从浏览器复制 JWT 并在 Authorization: Bearer hea
如何使用 powershell 设置服务主体的回复 URL。当我检查管理门户时,以下命令不会向该字段添加任何内容。 $aa = new-AzureADApplication -DisplayName“
我有 React 前端应用程序和 AWS lambda 后端。我已经使用 MSAL 将 AzureAD 身份验证集成到我的 React 应用程序中。我想澄清一些事情 用户登录前端后,我想调用我的后端
使用 AzureAD 模块,我可以使用 Get-AzureADServicePrincipalOAuth2PermissionGrant cmdlet 检索服务主体的所有委派权限。但是,我找不到类似的
我是一名优秀的程序员,十分优秀!