title | description | author | ms.author | ms.date | ms.topic | ms.service | ms.custom |
---|---|---|---|---|---|---|---|
Quickstart: Create an Azure SignalR Service - ARM template | In this Quickstart, learn how to create an Azure SignalR Service using an Azure Resource Manager template (ARM template). | vicancy | lianwei | 10/02/2020 | quickstart | azure-signalr-service | subject-armqs, mode-arm, devx-track-arm-template |
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.
[!INCLUDE About Azure Resource Manager]
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.
:::image type="content" source="~/reusable-content/ce-skilling/azure/media/template-deployments/deploy-to-azure-button.svg" alt-text="Button to deploy the Resource Manager template to Azure." border="false" link="https://portal.azure.com/#create/Microsoft.Template/uri/https%3a%2f%2fraw.githubusercontent.com%2fAzure%2fazure-quickstart-templates%2fmaster%2fquickstarts%2fmicrosoft.signalrservice%2fsignalr%2fazuredeploy.json":::
An Azure account with an active subscription. Create one for free.
- An Azure account with an active subscription. Create one for free.
- If you want to run the code locally, Azure PowerShell.
- An Azure account with an active subscription. Create one for free.
- If you want to run the code locally:
- A Bash shell (such as Git Bash, which is included in Git for Windows).
- Azure CLI.
The template used in this quickstart is from Azure Quickstart Templates.
:::code language="json" source="~/quickstart-templates/quickstarts/microsoft.signalrservice/signalr/azuredeploy.json":::
The template defines one Azure resource:
To deploy the Azure SignalR Service using the ARM template, Select the following link in the Azure portal:
:::image type="content" source="~/reusable-content/ce-skilling/azure/media/template-deployments/deploy-to-azure-button.svg" alt-text="Button to deploy the Resource Manager template to Azure." border="false" link="https://portal.azure.com/#create/Microsoft.Template/uri/https%3a%2f%2fraw.githubusercontent.com%2fAzure%2fazure-quickstart-templates%2fmaster%2fquickstarts%2fmicrosoft.signalrservice%2fsignalr%2fazuredeploy.json":::
On the Deploy an Azure SignalR Service page:
If you want, change the Subscription from the default.
For Resource group, select Create new, enter a name for the new resource group, and select OK.
If you created a new resource group, select a Region for the resource group.
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.
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.
:::image type="content" source="./media/signalr-quickstart-azure-signalr-service-arm-template/deploy-azure-signalr-service-arm-template-portal.png" alt-text="Screenshot of the ARM template for creating an Azure SignalR Service in the Azure portal.":::
Select Review + create.
Read the terms and conditions, and then select Create.
Note
If you want to run the PowerShell scripts locally, first enter Connect-AzAccount
to set up your Azure credentials.
Use the following code to deploy the Azure SignalR Service using the ARM template. The code prompts you for the following items:
- The name and region of the new Azure SignalR Service
- The name and region of a new resource group
- The Azure pricing tier (Free_F1 or Standard_S1)
- The SignalR unit capacity (1, 2, 5, 10, 20, 50, or 100)
[!NOTE] For the Free_F1 pricing tier, the capacity is limited to 1 unit.
- The service mode: Default to require a hub server, Serverless to disallow any server connection, or Classic to route to a hub server only if the hub has a server connection
- Whether to enable logs for connectivity or messaging (true or false)
$serviceName = Read-Host -Prompt "Enter a name for the new Azure SignalR Service" $serviceLocation = Read-Host -Prompt "Enter an Azure region (for example, westus2) for the service" $resourceGroupName = Read-Host -Prompt "Enter a name for the new resource group to contain the service" $resourceGroupRegion = Read-Host -Prompt "Enter an Azure region (for example, centralus) for the resource group" $priceTier = Read-Host -Prompt "Enter the pricing tier (Free_F1 or Standard_S1)" $unitCapacity = Read-Host -Prompt "Enter the number of SignalR units (1, 2, 5, 10, 20, 50, or 100)" $servicingMode = Read-Host -Prompt "Enter the service mode (Default, Serverless, or Classic)" $enableConnectionLogs = Read-Host -Prompt "Specify whether to enable connectivity logs (true or false)" $enableMessageLogs = Read-Host -Prompt "Specify whether to enable messaging logs (true or false)" Write-Verbose "New-AzResourceGroup -Name $resourceGroupName -Location $resourceGroupRegion" -Verbose New-AzResourceGroup -Name $resourceGroupName -Location $resourceGroupRegion $paramObjHashTable = @{ name = $serviceName location = $serviceLocation pricingTier = $priceTier capacity = [int]$unitCapacity serviceMode = $servicingMode enableConnectivityLogs = $enableConnectionLogs enableMessagingLogs = $enableMessageLogs } Write-Verbose "Run New-AzResourceGroupDeployment to create an Azure SignalR Service using an ARM template" -Verbose New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName ` -TemplateParameterObject $paramObjHashTable ` -TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.signalrservice/signalr/azuredeploy.json Read-Host "Press [ENTER] to continue"
Use the following code to deploy the Azure SignalR Service using the ARM template. The code prompts you for the following items:
- The name and region of the new Azure SignalR Service
- The name and region of a new resource group
- The Azure pricing tier (Free_F1 or Standard_S1)
- The SignalR unit capacity (1, 2, 5, 10, 20, 50, or 100)
[!NOTE] For the Free_F1 pricing tier, the capacity is limited to 1 unit.
- The service mode: Default to require a hub server, Serverless to disallow any server connection, or Classic to route to a hub server only if the hub has a server connection
- Whether to enable logs for connectivity or messaging (true or false)
read -p "Enter a name for the new Azure SignalR Service: " serviceName && read -p "Enter an Azure region (for example, westus2) for the service: " serviceLocation && read -p "Enter a name for the new resource group to contain the service: " resourceGroupName && read -p "Enter an Azure region (for example, centralus) for the resource group: " resourceGroupRegion && read -p "Enter the pricing tier (Free_F1 or Standard_S1): " priceTier && read -p "Enter the number of SignalR units (1, 2, 5, 10, 20, 50, or 100): " unitCapacity && read -p "Enter the service mode (Default, Serverless, or Classic): " servicingMode && read -p "Specify whether to enable connectivity logs (true or false): " enableConnectionLogs && read -p "Specify whether to enable messaging logs (true or false): " enableMessageLogs && params='name='$serviceName' location='$serviceLocation' pricingTier='$priceTier' capacity='$unitCapacity' serviceMode='$servicingMode' enableConnectivityLogs='$enableConnectionLogs' enableMessagingLogs='$enableMessageLogs && echo "CREATE RESOURCE GROUP: az group create --name $resourceGroupName --location $resourceGroupRegion" && az group create --name $resourceGroupName --location $resourceGroupRegion && echo "RUN az deployment group create, which creates an Azure SignalR Service using an ARM template" && az deployment group create --resource-group $resourceGroupName --parameters $params --template-uri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.signalrservice/signalr/azuredeploy.json && read -p "Press [ENTER] to continue: "
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.
Follow these steps to see an overview of your new Azure SignalR Service:
In the Azure portal, search for and select SignalR.
In the SignalR list, select your new service. The Overview page for the new Azure SignalR Service appears.
Run the following interactive code to view details about your Azure SignalR Service. You have to enter the name of the new service and the resource group.
$serviceName = Read-Host -Prompt "Enter the name of your Azure SignalR Service" $resourceGroupName = Read-Host -Prompt "Enter the resource group name" Write-Verbose "Get-AzSignalR -ResourceGroupName $resourceGroupName -Name $serviceName" -Verbose Get-AzSignalR -ResourceGroupName $resourceGroupName -Name $serviceName Read-Host "Press [ENTER] to continue"
Run the following interactive code to view details about your Azure SignalR Service. You have to enter the name of the new service and the resource group.
read -p "Enter the name of your Azure SignalR Service: " serviceName && read -p "Enter the resource group name: " resourceGroupName && echo "SHOW SERVICE DETAILS: az signalr show --resource-group $resourceGroupName --name $serviceName" && az signalr show --resource-group $resourceGroupName --name $serviceName && read -p "Press [ENTER] to continue: "
When it's no longer needed, delete the resource group, which deletes the resources in the resource group.
In the Azure portal, search for and select Resource groups.
In the resource group list, choose the name of your resource group.
In the Overview page of your resource group, select Delete resource group.
In the confirmation dialog box, type the name of your resource group, and then select Delete.
$resourceGroupName = Read-Host -Prompt "Enter the name of the resource group to delete" Write-Verbose "Remove-AzResourceGroup -Name $resourceGroupName" -Verbose Remove-AzResourceGroup -Name $resourceGroupName Read-Host "Press [ENTER] to continue"
read -p "Enter the name of the resource group to delete: " resourceGroupName && echo "DELETE A RESOURCE GROUP (AND ITS RESOURCES): az group delete --name $resourceGroupName" && az group delete --name $resourceGroupName && read -p "Press [ENTER] to continue: "
For a step-by-step tutorial that guides you through the process of creating an ARM template, see:
[!div class="nextstepaction"] Tutorial: Create and deploy your first ARM template