Azure InvalidTemplate Error: The language expression property array index '1' is out of bounds.

I'm trying to spin up a Redis Cache in Azure and placed it in my Virtual Network. However, it threw an error and the error message was not helping but I eventually figured it out.

Here's my Bicep template which threw an error:

resource cacheSubnet 'Microsoft.Network/virtualNetworks/subnets@2023-11-01' existing = {
name: 'mySubnet'
}

resource redis 'Microsoft.Cache/redis@2023-08-01' = {
name: 'myRedis'
location: resourceGroup().location
properties: {
enableNonSslPort: true
publicNetworkAccess: 'Disabled'
sku: {
capacity: 1
family: 'P'
name: 'Premium'
}
subnetId: cacheSubnet.id
}


Apparently, I needed the parent field on the subnet reference, so I ended with the following template which successfully launched my Redis cache.

resource vNet 'Microsoft.Network/virtualNetworks@2023-11-01' existing = {
name: 'myVNet'
}


resource cacheSubnet 'Microsoft.Network/virtualNetworks/subnets@2023-11-01' existing = {
name: 'mySubnet'
parent: vNet
}

resource redis 'Microsoft.Cache/redis@2023-08-01' = {
name: 'myRedis'
location: resourceGroup().location
properties: {
enableNonSslPort: true
publicNetworkAccess: 'Disabled'
sku: {
capacity: 1
family: 'P'
name: 'Premium'
}
subnetId: cacheSubnet.id
}

Comments

Popular posts from this blog

Sentinel One Strikes Again. No internet connection. Uninstall Sentinel One Agent.

A2 Hosting Let's Encrypt Can't Install Certificate on ASP.NET Core Application

NuGet Package Reference NU6105 Publish Error