Azure Bicep - Refer Existing Resource
Azure Bicep - Refer Existing Resource

Azure Bicep – Using Existing Resources in Code

In previous article, we have seen how the Azure Bicep can have conditions to create the services. Sometimes, the resource is not required to be created, because it is already present. But although the resources is not being created, some if its properties may be needed for creating other resources. Let’s have a look at a special keyword which can be used for this purpose.

The Existing Keyword

We still need to use the same keyword resource to refer an existing resource. But for referring an existing resource, we can use the keyword existing on the same line.

So, when we use existing keyword, the resource is not created. Instead, the properties of existing resource can be accessed via symbolic name specified in the resource. We just need to specify the name of the resource that we want to refer.

As we know we can have different target scopes specified at the top of the file. If we want to refer the existing resource from another scope as well. In that case, we need to specify resource name and the scope as well.


The code snippet given below shows two examples of existing keyword. First example shows how the resource from same scope can be referred and second example shows how to refer resource from another scope.

I hope you find this information helpful. Let me know your thoughts.

Leave a ReplyCancel reply