Azure / azure-resource-manager-schemas

Schemas used to author and validate Resource Manager Templates. These schemas power the intellisense and syntax completion in our ARM Tools VSCode extension, as well as the Export Template API
MIT License
611 stars 517 forks source link

Schema issues with Microsoft.Network/dnszones 2018-05-01 #1107

Open MWL88 opened 4 years ago

MWL88 commented 4 years ago

When adding a Microsoft.Network/dnszones resource to a template in VS Code the tooling offers etag as an available property: image

I am not sure when it would make sense to supply an etag in an ARM template ... but if I add an etag property VS Code says the template validation failed: image

I assume the etag property should not be present in the ARM template schema and not suggested by VS Code.

Why is the properties property required? It does not have any child properties that are marked as required and it is not required to successfully deploy a DNS zone: image

anthony-c-martin commented 4 years ago

@StephenWeatherford Can you think of a reason why the validation in the ARM tools extension is suggesting "etag" and then rejecting it once it's entered? Is it possible we're falling back to the generic resource definition at this point rather than validating against Microsoft.Network/dnsZones?

@apclouds We'll need to discuss the required properties field with the Network team - if it's not a requirement then we'll need them to adjust their schema generation to take this into account. They're not onboarded for automatic generation.

ghost commented 4 years ago

Hello @armleads-azure, @apclouds, @anthony-c-martin, @jorgecotillo! It looks like there is a schemas issue that needs your attention. Please investigate and confirm it is on your end. Thanks :smile:

StephenWeatherford commented 4 years ago

The field of possible top-level properties under a resource node is fixed, right (https://docs.microsoft.com/en-us/azure/azure-resource-manager/templates/template-syntax#resources)? @jorgecotillo's template validation code checks against this static list, I think.

The completion comes from the schemas only, so this would suggest the resource schema incorrectly specifies "etag" as a property. Can you verify?

StephenWeatherford commented 4 years ago

@anthony-c-martin Indeed the dnszones schema has an etag property:

{
    "id": "https://schema.management.azure.com/schemas/2018-05-01/Microsoft.Network.json#",
    "$schema": "http://json-schema.org/draft-04/schema#",
    "title": "Microsoft.Network",
    "description": "Microsoft Network Resource Types",
    "resourceDefinitions": {
        "dnsZones": {
            "type": "object",
            "properties": {
                "name": {
                    "type": "string"
                },
                "type": {
                    "type": "string",
                    "enum": [
                        "Microsoft.Network/dnsZones"
                    ]
                },
                "apiVersion": {
                    "type": "string",
                    "enum": [
                        "2018-05-01"
                    ]
                },
                "location": {
                    "type": "string",
                    "description": "Resource location."
                },
                "tags": {
                    ...
                    "description": "Resource tags."
                },
                "etag": { <<<<<<<<<<<<<<<<<<<<<
                    "type": "string",
                    "description": "The etag of the zone."
                },

But the documentation says nothing about it: https://docs.microsoft.com/en-us/azure/templates/microsoft.network/2018-05-01/dnszones