Bicep Deploying of API Tags reporting empty 'name' field

Shawn Pottle 1 Reputation point
2021-10-05T17:28:15.257+00:00

Hello,

I believe code speaks volumes better than descriptions:

param service_name string = '**********'

resource service_name_resource 'Microsoft.ApiManagement/service@2021-01-01-preview' existing = {
  name: service_name
}

//Tags
resource service_TestTag 'Microsoft.ApiManagement/service/tags@2021-01-01-preview' = {
  parent: service_name_resource
  name: 'TestTag'
}

Currently, when I try to deploy the script via DevOps pipeline, this script complains that the "'name' should not be empty". As shown in the code, the value is if anything, not empty. There is no tag with a similar name.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,447 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ken Muse 6 Reputation points Microsoft Employee
    2022-01-13T05:25:28.54+00:00

    It's not documented, but tags resources appear to require the displayName property. It must be configured to match the name to avoid potential issues with other parts of APIM. If this property is not provided, you will see the error message indicating 'name should not be empty'. This may be a bug in the resource provider. I also recommend moving to a later schema, such as 2021-08-01 so that you're not working with a preview API version.

    Because this modification conflicts with the documented schema for that resource type, you'll need to also take advantage of a newer Bicep feature, #disable-next-line. This eliminates the warning (BCP073) that you receive indicating that property is read-only.

    Hopefully this gives you a viable workaround, @Shawn Pottle . The modified code:

       //Tags  
       resource service_TestTag 'Microsoft.ApiManagement/service/tags@2021-08-01' = {  
         parent: service_name_resource  
         name: 'TestTag'  
         properties: {  
           #disable-next-line BCP073  
           displayName: 'TestTag'  
         }  
       }  
    
    1 person found this answer helpful.
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.