onlyIfNotExists() fails on first creation of a Blob private endpoint with PreconditionFailedResourceAlreadyExists

Open
#20,634 2 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
azure

Research direction

Start by tracing how Bicep compiles @onlyIfNotExists() to ARM JSON and how deployments handle the generated NIC for Microsoft.Network/privateEndpoints@2023-11-01. Compare the failing and successful templates described in the report, then investigate the endpoint and NIC requests with the ARM Deployments and Microsoft.Network Private Link teams. Done means establishing whether create-only is supported for this API version and identifying which request triggers the precondition failure.

Written by the indexing model from the issue text.

Description

AI Triaged Needs: Triage :mag: OnlyifNotExists

Bicep version

Bicep CLI 0.48.1 (cec7951cf6).

Describe the bug

Applying @onlyIfNotExists() to a new Microsoft.Network/privateEndpoints@2023-11-01 resource causes the deployment to fail on its Azure-generated network interface (NIC). An ordinary first create succeeds under the same conditions.

Expected: Since the endpoint name is unused, Azure creates the endpoint and its NIC.

Actual: The endpoint reports Failed. Its NIC reports Succeeded, and the Blob connection reports Approved. The endpoint operation returns PreconditionFailedResourceAlreadyExists:

If-none-match header (*) was specified in the request but resource <generated NIC resource ID> already exists.

To Reproduce

  1. In a disposable resource group, create a StorageV2 account (Standard_LRS) and a VNet with a subnet for private endpoints. We tested in westus2.
  2. Deploy a Microsoft.Network/privateEndpoints@2023-11-01 resource targeting the account's blob subresource. Use an unused endpoint name and let Azure allocate the NIC. This succeeds.
  3. Deploy the same template to the same account and subnet, using another unused endpoint name, with @onlyIfNotExists() immediately above the private endpoint declaration. This fails with the error above.

Additional context

Both cases were deployed from compiled ARM JSON with languageVersion: 2.0. Apart from the generated template hash, the only template difference was the endpoint's @options.onlyIfNotExists setting. Neither template declares a NIC.

Follow-up to Bicep discussion #20633. Could ARM Deployments and the Microsoft.Network Private Link team trace the endpoint and NIC requests and confirm whether create-only is supported for this API version? The deployment history identifies the NIC in the failed precondition but does not show which internal request supplied the header or whether a retry occurred. I can provide the failed lab deployment's ARM correlation ID privately.

Dominant language
Bicep
Stars
3.7k
Forks
833
Avg merge
1d 17h
Merged PRs (30d)
81

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/bicep

All issues in Azure/bicep

Similar issues

More Cloud issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.