Επεξεργασία

Quickstart: Use an ARM template to deploy Azure SignalR Service

This quickstart walks you through the process of creating an Azure SignalR Service using an Azure Resource Manager (ARM) template. You can deploy the Azure SignalR Service through the Azure portal, PowerShell, or CLI.

An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.

If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template opens in the Azure portal once you sign in.

Button to deploy the Resource Manager template to Azure.

Prerequisites

An Azure account with an active subscription. Create one for free.

Review the template

The template used in this quickstart is from Azure Quickstart Templates.

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.9.1.41621",
      "templateHash": "7185938028783900711"
    }
  },
  "parameters": {
    "name": {
      "type": "string",
      "defaultValue": "[uniqueString(resourceGroup().id)]",
      "metadata": {
        "description": "The globally unique name of the SignalR resource to create."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for the SignalR resource."
      }
    },
    "pricingTier": {
      "type": "string",
      "defaultValue": "Standard_S1",
      "allowedValues": [
        "Free_F1",
        "Standard_S1",
        "Premium_P1"
      ],
      "metadata": {
        "description": "The pricing tier of the SignalR resource."
      }
    },
    "capacity": {
      "type": "int",
      "defaultValue": 1,
      "allowedValues": [
        1,
        2,
        5,
        10,
        20,
        50,
        100
      ],
      "metadata": {
        "description": "The number of SignalR Unit."
      }
    },
    "serviceMode": {
      "type": "string",
      "defaultValue": "Default",
      "allowedValues": [
        "Default",
        "Serverless",
        "Classic"
      ],
      "metadata": {
        "description": "Visit https://github.com/Azure/azure-signalr/blob/dev/docs/faq.md#service-mode to understand SignalR Service Mode."
      }
    },
    "enableConnectivityLogs": {
      "type": "bool",
      "defaultValue": true
    },
    "enableMessagingLogs": {
      "type": "bool",
      "defaultValue": true
    },
    "enableLiveTrace": {
      "type": "bool",
      "defaultValue": true
    },
    "allowedOrigins": {
      "type": "array",
      "defaultValue": [
        "*"
      ],
      "metadata": {
        "description": "Set the list of origins that should be allowed to make cross-origin calls."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.SignalRService/signalR",
      "apiVersion": "2022-02-01",
      "name": "[parameters('name')]",
      "location": "[parameters('location')]",
      "sku": {
        "capacity": "[parameters('capacity')]",
        "name": "[parameters('pricingTier')]"
      },
      "kind": "SignalR",
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "tls": {
          "clientCertEnabled": false
        },
        "features": [
          {
            "flag": "ServiceMode",
            "value": "[parameters('serviceMode')]"
          },
          {
            "flag": "EnableConnectivityLogs",
            "value": "[string(parameters('enableConnectivityLogs'))]"
          },
          {
            "flag": "EnableMessagingLogs",
            "value": "[string(parameters('enableMessagingLogs'))]"
          },
          {
            "flag": "EnableLiveTrace",
            "value": "[string(parameters('enableLiveTrace'))]"
          }
        ],
        "cors": {
          "allowedOrigins": "[parameters('allowedOrigins')]"
        },
        "networkACLs": {
          "defaultAction": "Deny",
          "publicNetwork": {
            "allow": [
              "ClientConnection"
            ]
          },
          "privateEndpoints": [
            {
              "name": "mySignalRService.1fa229cd-bf3f-47f0-8c49-afb36723997e",
              "allow": [
                "ServerConnection"
              ]
            }
          ]
        },
        "upstream": {
          "templates": [
            {
              "categoryPattern": "*",
              "eventPattern": "connect,disconnect",
              "hubPattern": "*",
              "urlTemplate": "https://example.com/chat/api/connect"
            }
          ]
        }
      }
    }
  ]
}

The template defines one Azure resource:

Deploy the template

To deploy the Azure SignalR Service using the ARM template, Select the following link in the Azure portal:

Button to deploy the Resource Manager template to Azure.

On the Deploy an Azure SignalR Service page:

  1. If you want, change the Subscription from the default.

  2. For Resource group, select Create new, enter a name for the new resource group, and select OK.

  3. If you created a new resource group, select a Region for the resource group.

  4. If you want, enter a new Name and the Location (For example eastus2) of the Azure SignalR Service. If Name is not specified, it is generated automatically. The Location can be the same or different from the region of the resource group. If Location is not specified, it defaults to the same region as your resource group.

  5. Choose the Pricing Tier (Free_F1 or Standard_S1), enter the Capacity (number of SignalR units), and choose a Service Mode of Default (requires hub server), Serverless (doesn't allow any server connection), or Classic (routed to hub server only if hub has server connection). Now, choose whether to Enable Connectivity Logs or Enable Messaging Logs.

    Note

    For the Free_F1 pricing tier, the capacity is limited to 1 unit.

    Screenshot of the ARM template for creating an Azure SignalR Service in the Azure portal.

  6. Select Review + create.

  7. Read the terms and conditions, and then select Create.

Note

The deployment may take a few minutes to complete. Note the names for the Azure SignalR Service and the resource group, which you use to review the deployed resources later.

Review deployed resources

Follow these steps to see an overview of your new Azure SignalR Service:

  1. In the Azure portal, search for and select SignalR.

  2. In the SignalR list, select your new service. The Overview page for the new Azure SignalR Service appears.

Clean up resources

When it's no longer needed, delete the resource group, which deletes the resources in the resource group.

  1. In the Azure portal, search for and select Resource groups.

  2. In the resource group list, choose the name of your resource group.

  3. In the Overview page of your resource group, select Delete resource group.

  4. In the confirmation dialog box, type the name of your resource group, and then select Delete.

Next steps

For a step-by-step tutorial that guides you through the process of creating an ARM template, see: