Azure / Azure/azure-quickstart-templates
100-marketplace-sample deployment fails when selecting None for public IP
- Dominant language
- Bicep
- Stars
- 14.9k
- Forks
- 16.2k
- Avg merge
- 6d 21h
- Merged PRs (30d)
- 6
Description
### Template
[100-marketplace-sample](https://github.com/Azure/azure-quickstart-templates/blob/master/100-marketplace-sample/azuredeploy.json)
### Issue Details
If I select None for the Microsoft.Network.PublicIpAddressCombo in createUiDefinition.json, Azure will output an empty string for the [publicIpName](https://github.com/Azure/azure-quickstart-templates/blob/master/100-marketplace-sample/createUiDefinition.json#L173) variable. This is true both in the [Create UI Definition Sandbox](https://portal.azure.com/?feature.customPortal=false#blade/Microsoft_Azure_CreateUIDef/SandboxBlade) and in the production Azure portal.
When publicIpName is consumed in azuredeploy.json the validation will fail because the empty string is not valid. The following unhelpful error message is produced:
`Deployment template validation failed: 'The template resource '' at line '' and column '' is not valid. The name property cannot be null or empty. Please see https://aka.ms/arm-template/#resources for usage details.'`
Azure seems to still want a valid name even though the Public IP address is not created (because the condition check fails).
### Workaround
I'm not sure what the correct solution should be, but I can get the template to validate if I provide a default string (given by a new variable) for the publicIpName in the two places it is consumed in azuredeploy.json.
For example:
Defining the name for the Microsoft.Network/publicIPAddresses resource at [azuredeploy.json:252](https://github.com/Azure/azure-quickstart-templates/blob/master/100-marketplace-sample/azuredeploy.json#L252)
` "name": "[if(equals(parameters('publicIpNewOrExisting'), 'new'), parameters('publicIpName'), variables('publicIpNameNone'))]" `
Dependency in Microsoft.Network/networkInterfaces at [azuredeploy.json:313](https://github.com/Azure/azure-quickstart-templates/blob/master/100-marketplace-sample/azuredeploy.json#L313)
` "[if(equals(parameters('publicIpNewOrExisting'), 'new'), parameters('publicIpName'), variables('publicIpNameNone'))]" `
Note that the default value "PublicIp" at [azuredeploy.json:143](https://github.com/Azure/azure-quickstart-templates/blob/master/100-marketplace-sample/azuredeploy.json#L143) is not used because of the empty string output from createUiDefinition.json.
Thanks
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with createUiDefinition.json at the publicIpName reference around line 173, then inspect its two consumers in azuredeploy.json around lines 252 and 313. Reproduce the deployment with None selected for the public IP in the Create UI Definition Sandbox or Azure portal; done means the template validates and deploys without the empty-name error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- azure
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100