azure - 如何使用PowerShell创建客户端 key ?

标签 azure powershell

我是网络开发领域的新手。我开发了一个 ASP .NET Core Web 应用程序,该应用程序已在我的组织的 Azure 门户中注册。此 Web 应用程序使用 Microsoft Graph API,因此需要客户端 key 才能工作。

嗯,我的问题是 azure 门户中的 UI 不允许我创建永不过期的客户端 key 。我读到您可以使用 PowerShell 创建客户端 key 。它是如何工作的?创建后,此 secret 会在 azure 门户的“应用程序注册”中可见吗?我是否需要在 PowerShell 中执行特定存储库中的代码?从未使用过这个工具,所以我有点迷失。

请随时将我引向好的方向!

最佳答案

您可以从远程 PowerShell 或 azure cli 中的 PowerShell 创建客户端 key 。

  • 如果您想从远程 PowerShell 连接到 Azure AD,则需要安装 Azure AD 模块。

  • 在管理员模式下在 PowerShell 中运行以下安装命令。

Install-Module -Name AzureAD
  • 这里是安装引用文档Azure AD modules
  • 以下是在 Azure 事件目录中创建新应用注册的命令列表,后跟客户端 key 。
connect-AzureAD
    $azureADAppReg = New-AzureADApplication -DisplayName NewStackTest -AvailableToOtherTenants $false -IdentifierUris 'https://local host'
    New-AzureADApplicationPasswordCredential -CustomKeyIdentifier PrimarySecret -ObjectId $azureADAppReg.ObjectId -EndDate ((Get-Date).AddMonths(6))
  • 从 PowerShell 创建客户端 key 后,它将自动反射(reflect)在 Azure 门户中,并且在应用注册中的客户端和 key 下可见。

关于azure - 如何使用PowerShell创建客户端 key ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68022133/

相关文章:

sql-server - 如何找出导致 Azure SQL 数据库出现数据 IO 峰值的原因?

Azure 应用服务 VNET 与内部 DNS 集成

Powershell - 自定义模块的输出不可用

powershell - 获取VS2015中的Nuget软件包的许可证

powershell - 连字符/破折号参数对PowerShell意味着什么?

powershell - 在 Powershell 中绑定(bind)到不同的事件目录 ldap 实例

powershell - 使用全局热键调用 powershell 函数

html - 使用 Azure Bot Framework Web 聊天无法单击电话号码

azure - 有没有办法在管道之间创建依赖关系? (单个管道依赖于其他 3 个管道)

azure - Visual Studio 2013 Azure 云服务项目看不到已创建的云服务