Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/design-patterns/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure AD应用程序通过Powershell添加密钥_Azure_Azure Active Directory_Azure Powershell - Fatal编程技术网

Azure AD应用程序通过Powershell添加密钥

Azure AD应用程序通过Powershell添加密钥,azure,azure-active-directory,azure-powershell,Azure,Azure Active Directory,Azure Powershell,我正在尝试使用PowerShell在Azure广告应用程序中添加密钥。不幸的是,我首先尝试使用Azure CLI,但经过一些研究和一些stackoverflow答案后,我发现这是不可能做到的 我正在尝试通过Powershell从以下链接自动执行任务: 我还将遵循以下步骤: 是否有任何方法可以在Powershell中创建/检索以下内容: Vault URL, AuthClientId, AuthClientSecret。下面将从现有AD应用程序检索ClientID: $ADApp = Get-A

我正在尝试使用PowerShell在Azure广告应用程序中添加密钥。不幸的是,我首先尝试使用Azure CLI,但经过一些研究和一些stackoverflow答案后,我发现这是不可能做到的

我正在尝试通过Powershell从以下链接自动执行任务:

我还将遵循以下步骤:

是否有任何方法可以在Powershell中创建/检索以下内容:

Vault URL, AuthClientId,
AuthClientSecret。

下面将从现有AD应用程序检索ClientID:

$ADApp = Get-AzureRmADApplication -DisplayName "AzureADApplicationName"
write-host $ADApp.ApplicationId
下面将检索Vault Uri:

$KeyVault= Get-AzureRmKeyVault -VaultName "VaultName"
write-host $KeyVault.VaultUri

我也在寻找从powershell添加密钥的选项。当我手动添加密钥时,会显示一条消息,上面写着“复制并存储密钥值。离开此页面后,您将无法检索它”。但仍在试图找到使用powershell检索密钥(ClientSecret)的选项。

在powershell中创建AAD应用程序并保留密钥记录的唯一方法是使用Graph API。这样,我就可以自己生成键值并显式地传递它,而不是试图在输出中捕获它


这里的脚本:

这可以使用New AzureRmADApplication(在创建应用程序时包含它)方法来完成,但显然不能使用Set-AzureMadapplication(即在创建应用程序后设置它;我不确定是否有办法通过powershell实现)。但仅仅从了解方法的角度,还不清楚如何设置。这个网站让我找到了答案:

要点是,您必须提供这些方法所指的密码凭据,尽管Azure门户似乎将其称为密钥,而某些powershell命令(如SqlAzureAuthenticationContext)则会调用您正在设置秘密的值(所有这些都是令人困惑的术语)。下面是我如何使用凭据创建的:

# 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

我也有同样的问题,你解决了吗?没有。还没有找到从脚本中检索它的方法。目前我正在手动执行此操作。使用最新版本的AzureRM,PSADPasswordCredentials对象已移动到Microsoft.Azure.Graph.RBAC.Version1_6.ActiveDirectory.PSADPasswordCredential