Create a Web App plus Azure Cache for Redis using Bicep

In this article, you use Bicep to deploy an Azure Web App that uses Azure Cache for Redis, as well as an App Service plan.

Bicep is a domain-specific language (DSL) that uses declarative syntax to deploy Azure resources. It provides concise syntax, reliable type safety, and support for code reuse. Bicep offers the best authoring experience for your infrastructure-as-code solutions in Azure.

You can use this Bicep file for your own deployments. The Bicep file provides unique names for the Azure Web App, the App Service plan, and the Azure Cache for Redis. If you'd like, you can customize the Bicep file after you save it to your local device to meet your requirements.

For more information about creating Bicep files, see Quickstart: Create Bicep files with Visual Studio Code. To learn about Bicep syntax, see Understand the structure and syntax of Bicep files.

Review the Bicep file

The Bicep file used in this quickstart is from Azure Quickstart Templates.

@description('Describes plan\'s pricing tier and instance size. Check details at')
param skuName string = 'F1'

@description('Describes plan\'s instance count')
param skuCapacity int = 1

@description('The pricing tier of the new Azure Redis Cache.')
param cacheSKUName string = 'Basic'

@description('The family for the sku.')
param cacheSKUFamily string = 'C'

@description('The size of the new Azure Redis Cache instance. ')
param cacheSKUCapacity int = 0

@description('Location for all resources.')
param location string = resourceGroup().location

var hostingPlanName = 'hostingplan${uniqueString(resourceGroup().id)}'
var webSiteName = 'webSite${uniqueString(resourceGroup().id)}'
var cacheName = 'cache${uniqueString(resourceGroup().id)}'

resource hostingPlan 'Microsoft.Web/serverfarms@2021-03-01' = {
  name: hostingPlanName
  location: location
  tags: {
    displayName: 'HostingPlan'
  sku: {
    name: skuName
    capacity: skuCapacity
  properties: {

resource webSite 'Microsoft.Web/sites@2021-03-01' = {
  name: webSiteName
  location: location
  tags: {
    'hidden-related:${}': 'empty'
    displayName: 'Website'
  identity: {
    type: 'SystemAssigned'
  properties: {
    httpsOnly: true
  dependsOn: [

resource appsettings 'Microsoft.Web/sites/config@2021-03-01' = {
  parent: webSite
  name: 'appsettings'
  properties: {
    CacheConnection: '${cacheName},abortConnect=false,ssl=true,password=${cache.listKeys().primaryKey}'
    minTlsVersion: '1.2'
    ftpsState: 'FtpsOnly'

resource cache 'Microsoft.Cache/Redis@2021-06-01' = {
  name: cacheName
  location: location
  tags: {
    displayName: 'cache'
  properties: {
    sku: {
      name: cacheSKUName
      family: cacheSKUFamily
      capacity: cacheSKUCapacity

With this Bicep file, you deploy:

Deploy the Bicep file

  1. Save the Bicep file as main.bicep to your local computer.

  2. Deploy the Bicep file using either Azure CLI or Azure PowerShell.

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep

    When the deployment finishes, you should see a message indicating the deployment succeeded.

Review deployed resources

Use the Azure portal, Azure CLI, or Azure PowerShell to list the deployed resources in the resource group.

az resource list --resource-group exampleRG

Clean up resources

When no longer needed, use the Azure portal, Azure CLI, or Azure PowerShell to delete the resource group and its resources.

az group delete --name exampleRG

Next steps

To learn more about Bicep, continue to the following article: