Azure / Azure/bicep

Bicep missed creation of resources even though the deployment was successful

Open
#17,999 7 comments 0 reactions 0 assignees View on GitHub
Error Handling story: scopes
Dominant language
Bicep
Stars
3.6k
Forks
830
Avg merge
1d 2h
Merged PRs (30d)
79

Description

**Bicep version**
Azure cli version 2.259.1. Using the command az deployment group create

**Describe the bug**
I have added 4 new service bus topics and with that also 4 subscriptions. When deploying the bicep through my environments the behavior was like this:
dev: Bicep deploy success, resources there
tst: bicep deploy succces, subscriptions missing
uat: bicep deploy success, resources there
prd: bicep deploy success, subscriptions missing.

This caused us to lose a lot of messages. When retrying the resources where created. In this case it was about logging messages but it could have caused major issues for us!

**To Reproduce**

This is some of the bicep:
```bicep
module serviceBusTopicSubscriptions '../Logging/ServiceBusTopicSubscriptions.bicep' = [for topic in topics: {
name: 'ServiceBus-Subs-${topic}'
scope: resourceGroup(serviceBusResourceGroup)
params: {
serviceBusName: serviceBusName
topicName: topic
sbtsLoggingName: sbtsLoggingName
}
}]
```
Calls this module:
```bicep
param serviceBusName string
param topicName string
param sbtsLoggingName string

module loggingTopicSubscription '../Modules/ServiceBus-Topic-Subscription-module.bicep' = {
name: sbtsLoggingName
params:{
serviceBusName: serviceBusName
topicName: topicName
subscriptionName: sbtsLoggingName
}
}
```

calls this module:
```bicep
param serviceBusName string
param topicName string
param subscriptionName string
param messageTimeToLive string = 'P14D'

resource azServiceBus 'Microsoft.ServiceBus/namespaces@2022-10-01-preview' existing = {
name: serviceBusName
}

resource azServiceBusTopic 'Microsoft.ServiceBus/namespaces/topics@2022-10-01-preview' existing = {
parent: azServiceBus
name: topicName
}

resource azServiceBusTopicSubscription 'Microsoft.ServiceBus/namespaces/topics/subscriptions@2022-10-01-preview' = {
parent: azServiceBusTopic
name: subscriptionName
properties: {
requiresSession: false
defaultMessageTimeToLive: messageTimeToLive
deadLetteringOnMessageExpiration: false
maxDeliveryCount: 10
autoDeleteOnIdle: ''
}
}
```

Steps to reproduce the behavior:
Hard to say as it feels random.

**Additional context**
It shows that bicep and the result of it is absolutely distrust worthy and caused me to seriously question how to work with bicep going forward.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing the deployment with az deployment group create and the two referenced modules, ../Logging/ServiceBusTopicSubscriptions.bicep and ../Modules/ServiceBus-Topic-Subscription-module.bicep. Compare deployment results with the created Service Bus subscriptions across environments. Done means the intermittent missing-resource behavior has a reproducible cause and an actionable resolution.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure
Domain
cloud, infrastructure
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.