powershell - 从 PowerShell 部署受 Azure Active Directory 保护的 Service Fabric

标签 powershell azure teamcity azure-service-fabric

我正在尝试通过 PowerShell 调用 Deploy-FabricApplication.ps1 作为 TeamCity 构建配置的一部分,发布到使用 Azure Active Directory 保护的服务结构集群。

我无法找到您在这种情况下如何提供凭据。

我确实在 Deploy-FabricApplication.ps1 中注意到 Active Directory 有一个 SecurityToken 参数。

这是您需要传递的信息来进行身份验证吗?如果是这样,您如何在 PowerShell 中生成安全 token ?

我已在 TeamCity 的 Azure Active Directory 中设置了一个用户,我希望对其进行身份验证。

最佳答案

可以通过使用 Active Directory 身份验证库 (ADAL) 来获取 token ,特别是通过调用方法 AcquireTokenMicrosoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext .

VSTS Service Fabric 部署 任务的代码中可以看到一个很好的使用示例:https://github.com/Microsoft/vsts-tasks/blob/master/Tasks/ServiceFabricDeploy/utilities.ps1

该文件中有一个名为 Get-AadSecurityToken 的函数其中显示对 AuthenticationContext.AcquireToken 的调用方法。

您需要确保拥有集群应用 ID客户端应用 ID。这两个都可以通过调用Connect-ServiceFabricCluster从集群中检索。与 -GetMetadata切换(这也是在 Get-AadSecurityToken 函数中完成的)。

关于powershell - 从 PowerShell 部署受 Azure Active Directory 保护的 Service Fabric,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40355178/

相关文章:

teamcity - 在 TeamCity 中实现 "all except"权限

proxy - TeamCity - 代理背后导致构建失败

regex - 如何查找和替换文本文件中所有出现的 "(percentage)%"并替换为用户提供的整数

Powershell if 条件在某些存在时不返回结果

azure - 从 CLI 触发 Azure 策略中的合规性扫描

asp.net - 代码无效或已过期。使用 API 调用显式使 session 无效

windows - 如何在 PowerShell 中获取错误的行号

sql-server - powershell 从表中提取值

azure - 无法使用 Visual Studio 发布 Azure Function : Create button disabled

continuous-integration - 如何在没有 Web 部署项目的情况下在 VS 2012 中处理 Web 应用程序项目的构建?