gpt4 book ai didi

azure - 尝试将证书添加到 azure 应用程序时出现错误 "Service principal was not found"

转载 作者:行者123 更新时间:2023-12-02 06:09:55 25 4
gpt4 key购买 nike

我正在按照 https://azure.microsoft.com/en-us/documentation/samples/active-directory-dotnet-daemon-certificate-credential/ 上的示例进行操作使用 Azure AD 对带有证书的守护程序应用程序进行身份验证到服务应用程序。我已完成以下操作:

  • 创建我自己的 Active Directory
  • 在 AD 中创建守护程序应用程序名称:TodoListDaemonWithCertYanlin登录 URL:http://TodoListDaemonWithCertYanlin应用程序 ID 网址:http://TodoListDaemonWithCertYanlin
  • 创建自签名证书makecert -r -pe -n "CN=TodoListDaemonWithCertYanlin"-ss My -len 2048 TodoListDaemonWithCert.cer

当我尝试将证书添加到 PowerShell 中的守护程序应用程序时,出现错误。

我使用的 PowerShell 命令:New-MsolServicePrincipalCredential -AppPrincipalId "e5dedde0-2221-4ce4-a74d-af4e96705c01"-Type asymmetric -Value $credValue -StartDate $cer.GetEffectiveDateString() -EndDate $cer.GetExpirationDateString() -使用验证

错误是:New-MsolServicePrincipalCredential:找不到服务主体。

“Get-MsolServicePrincipal -SearchString TodoListDaemonWithCert”返回了一堆应用程序,但我的不包括在内。

我怀疑 Azure 可能会搜索我组织的 AD,而不是我创建的 AD。但我不知道如何调试这个问题。

最佳答案

问题已解决。

发生这种情况的原因如下:我使用组织的凭据登录到 Azure,然后创建了一个测试 Active Directory,并在我的测试 Active Directory 中创建了待办事项列表守护程序应用程序。当我在 PowerShell 中登录 Azure 时,我使用了我组织的凭据。似乎Azure PowerShell只会在我组织的AD中查找应用程序原理,而不是在我的测试AD中 - 可能有一种方法可以切换AD,但我还不知道。

以下是我解决问题的方法:

  • 前往 https://manage.windowsazure.com并尝试使用我的测试 AD 中的用户登录。
  • Azure 提示用户未与任何订阅关联。点击“注册”链接注册免费试用订阅。
  • 等待几分钟以配置租户
  • 在 PowerShell 中,使用我的测试 Azure AD 中的用户登录 azure,然后再次运行 PowerShell。现在成功了。

以下是我运行的 PowerShell cmdlet:

connect-msolservice
$cer = New-Object System.Security.Cryptography.X509Certificates.X509Certificate
$cer.Import("D:\Fast1\dev\TodoListDaemonWithCert.cer")
$binCert = $cer.GetRawCertData()
$credValue = [System.Convert]::ToBase64String($binCert)
New-MsolServicePrincipalCredential -AppPrincipalId "e5dedde0-2221-4ce4-a74d-af4e96705c01" -Type asymmetric -Value $credValue -StartDate $cer.GetEffectiveDateString() -EndDate $cer.GetExpirationDateString() -Usage verify

关于azure - 尝试将证书添加到 azure 应用程序时出现错误 "Service principal was not found",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33616359/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com