【问题标题】:Deploying Service Fabric secured by Azure Active Directory from PowerShell从 PowerShell 部署受 Azure Active Directory 保护的 Service Fabric
【发布时间】:2017-03-14 07:16:56
【问题描述】:

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

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

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

这是您需要传递以进行身份​​验证的内容吗?如果需要,您如何在 PowerShell 中生成安全令牌?

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

【问题讨论】:

    标签: powershell azure teamcity azure-service-fabric


    【解决方案1】:

    可以使用 Active Directory 身份验证库 (ADAL) 获取令牌,特别是通过调用 Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext 中的方法 AcquireToken

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

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

    您需要确保同时拥有集群应用 ID客户端应用 ID。这两者都可以通过使用-GetMetadata 开关调用Connect-ServiceFabricCluster 从集群中检索(这也在Get-AadSecurityToken 函数中完成)。

    【讨论】:

    • 稍作修改,我就可以毫无问题地获得该代码来生成我的securityToken。当我将该参数传递给部署脚本时,它返回错误:WARNING: Unable to Verify connection to Service Fabric cluster. Exception: at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord) Message : Cluster connection instance is null
    • 我的错,我忘了在调用脚本之前添加. 。感谢您的帮助
    猜你喜欢
    • 2018-12-11
    • 1970-01-01
    • 1970-01-01
    • 2021-09-14
    • 2017-01-05
    • 1970-01-01
    • 2020-03-11
    • 2017-11-05
    • 2015-07-27
    相关资源
    最近更新 更多