我正在尝试使用 PowerShell 在我的 Azure AD 应用程序中添加一个 key 。不幸的是,我首先尝试使用 Azure CLI,但经过一些研究和一些 stackoverflow 答案后,我发现这是无法完成的。

我正在尝试通过 Powershell 从下面的链接自动执行任务:http://blog.davidebbo.com/2014/12/azure-service-principal.html

我也在遵循以下步骤:
https://blogs.technet.microsoft.com/kv/2015/06/02/azure-key-vault-step-by-step/

有没有办法在 Powershell 中创建/检索以下内容:

保险库网址,
身份验证客户端 ID,
AuthClientSecret。

最佳答案

这可以使用 New-AzureRmADApplication 方法(在创建应用程序时包含它)来完成,但显然不能使用 Set-AzureRmADApplication(即在创建应用程序后设置它;我不确定有没有办法做到)通过powershell)。但是仅凭了解方法就不清楚如何设置它。这个网站让我找到了答案: https://sabin.io/blog/adding-an-azure-active-directory-application-and-key-using-powershell/

要点是您必须提供这些方法称为 PasswordCredentials 的内容,尽管 Azure 门户似乎将它们称为 key ,并且一些 powershell 命令(如 SqlAzureAuthenticationContext)调用您正在设置的值 Secret (所有这些都是令人困惑的术语)。以下是我使用凭证创建的方法:

# Be sure to note $KeyValue! It can't be retrieved.
# It's the "Secret" you can pass to methods like Add-SqlAzureAuthenticationContext in order to authenticate.
$KeyValue = [guid]::NewGuid()
Write-Output "The password you've set is $KeyValue"

$psadCredential = New-Object Microsoft.Azure.Commands.Resources.Models.ActiveDirectory.PSADPasswordCredential
$startDate = Get-Date
$psadCredential.StartDate = $startDate
$psadCredential.EndDate = $startDate.AddYears(1)
$psadCredential.KeyId = [guid]::NewGuid()
$psadCredential.Password = $KeyValue

$adApplication = New-AzureRmADApplication –DisplayName “MyNewApp”`
-HomePage "http://MyNewApp"`
-IdentifierUris "http://MyNewApp"`
-PasswordCredentials $psadCredential

关于Azure AD 应用程序通过 Powershell 添加 key ,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36833464/

10-12 14:18
查看更多