我正在尝试通过 PowerShell 调用 Deploy-FabricApplication.ps1 作为 TeamCity 构建配置的一部分,发布到使用 Azure Active Directory 保护的服务结构集群。
我无法找到您在这种情况下如何提供凭据。
我确实在 Deploy-FabricApplication.ps1 中注意到 Active Directory 有一个 SecurityToken 参数。
这是您需要传递的信息来进行身份验证吗?如果是这样,您如何在 PowerShell 中生成安全 token ?
我已在 TeamCity 的 Azure Active Directory 中设置了一个用户,我希望对其进行身份验证。
最佳答案
可以通过使用 Active Directory 身份验证库 (ADAL) 来获取 token ,特别是通过调用方法 AcquireToken
在Microsoft.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/