快速入门:使用 Bicep 创建通知中心
Azure 通知中心提供易于使用且横向扩展的推送引擎,允许你从任何后端(云或本地)向任何平台(iOS、Android、Windows、Kindle 等)发送通知。 有关此服务的详细信息,请参阅什么是 Azure 通知中心。
Bicep 是一种特定于域的语言 (DSL),使用声明性语法来部署 Azure 资源。 它提供简明的语法、可靠的类型安全性以及对代码重用的支持。 Bicep 会针对你的 Azure 基础结构即代码解决方案提供最佳创作体验。
本快速入门使用 Bicep 来创建 Azure 通知中心命名空间,并在命名空间中创建名为“MyHub”的通知中心。
如果没有 Azure 订阅,请在开始前创建一个试用版订阅帐户。
本快速入门中使用的 Bicep 文件来自 Azure 快速入门模板。
@description('The name of the Notification Hubs namespace.')
param namespaceName string
@description('The location in which the Notification Hubs resources should be deployed.')
param location string = resourceGroup().location
var hubName = 'MyHub'
resource namespace 'Microsoft.NotificationHubs/namespaces@2017-04-01' = {
name: namespaceName
location: location
sku: {
name: 'Free'
}
}
resource notificationHub 'Microsoft.NotificationHubs/namespaces/notificationHubs@2017-04-01' = {
name: hubName
location: location
parent: namespace
properties: {
}
}
Bicep 文件会创建两个 Azure 资源:
将该 Bicep 文件另存为本地计算机上的 main.bicep。
使用 Azure CLI 或 Azure PowerShell 来部署该 Bicep 文件。
az group create --name exampleRG --location chinaeast az deployment group create --resource-group exampleRG --template-file main.bicep --parameters namespaceName=<namespace-name>
备注
将命名空间名称<替换为>通知中心命名空间的名称。
部署完成后,应会看到一条指出部署成功的消息。
使用 Azure 门户、Azure CLI 或 Azure PowerShell 列出资源组中已部署的资源。
az resource list --resource-group exampleRG
如果不再需要逻辑应用,请使用 Microsoft Azure 门户、Azure CLI 或 Azure PowerShell 将资源组及其资源删除。
az group delete --name exampleRG
有关引导你完成 Bicep 文件创建过程的分步教程,请参阅: