Azure AD应用程序通过Powershell添加密钥 [英] Azure AD application adding a key via Powershell

查看:69
本文介绍了Azure AD应用程序通过Powershell添加密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I'm trying to add a key in my Azure AD application using PowerShell. Unfortunately i was try first with Azure CLI, but after some research and some stackoverflow answers I figure out, that this cannot be done.

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

I'm trying to automate the task from the link below via Powershell: http://blog.davidebbo.com/2014/12/azure-service-principal.html

我还按照以下步骤操作: https://博客. technet.microsoft.com/kv/2015/06/02/azure-key-vault-step-by-step/

I'm also following these steps: https://blogs.technet.microsoft.com/kv/2015/06/02/azure-key-vault-step-by-step/

有什么方法可以在Powershell中创建/检索以下内容:

Is there any way to create/retrieve the following things in Powershell:

VaultUrl, AuthClientId, AuthClientSecret.

VaultUrl, AuthClientId, AuthClientSecret.

推荐答案

可以使用方法New-AzureRmADApplication(在创建应用程序时将其包括在内)完成此操作,但显然不能使用Set-AzureRmADApplication(即进行设置)在创建应用程序后将其添加;我不确定是否可以通过Powershell来执行此操作).但是尚不清楚如何仅通过了解方法来设置它.该站点使我得到了答案: https://sabin.io/blog/adding-an-azure-active-directory-application-and-key-using-powershell/.

This can be done using either the method New-AzureRmADApplication (to include it when you create the application), but apparently not with Set-AzureRmADApplication (i.e. to set it after creating the app; I'm not sure there is a way to do that via powershell). But it's not clear how to set this just from knowing the methods. This site led me to the answer: https://sabin.io/blog/adding-an-azure-active-directory-application-and-key-using-powershell/.

要点是,尽管Azure门户似乎将这些方法称为密钥",但您必须提供这些方法所称为的密码,并且某些Powershell命令(例如SqlAzureAuthenticationContext)会调用您设置机密"的值(所有这些都令人困惑)条款).这是我使用凭证创建的方式:

The gist is that you have to provide what those methods refer to as PasswordCredentials, though the Azure portal seems to call them keys, and some powershell commands, like SqlAzureAuthenticationContext call the value you are setting the Secret (all of which are confusing terms). Here's how I did it to create with the credential:

# 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添加密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆