使用 PowerShell 在 Azure 通知中心创建授权规则

Creating Authorization Rule on Azure Notification Hub using PowerShell

是否有人设法使用 New-AzNotificationHubAuthorizationRule 或 New-AzNotificationHubsNamespaceAuthorizationRule 在通知中心或通知中心命名空间上创建授权规则?我找不到合适的例子?

文档指定

{
   "Name": "ContosoAuthorizationRule",
   "PrimaryKey": "WE4qH0398AyXjlekt56gg1gMR3NHoMs29KkUnnpUk01Y=",
   "Rights": [
      "Listen",
      "Send"
   ]
}

主键从哪里来?

除了官方文档,我在网上找不到任何示例,而且它们在细节上相当稀疏。

primary key描述在Description section结尾:

The PrimaryKey that is used for authentication, can be randomly generated by using the following Windows PowerShell command: [Convert]::ToBase64String((1..32 |% { [byte/](Get-Random -Minimum 0 -Maximum 255) }))

但是请注意命令中有一个小错误,你应该在上面的代码中使用[byte]而不是[byte/]

然后可以使用命令New-AzNotificationHubsNamespaceAuthorizationRule创建命名空间级别的规则: