bicep
bicep copied to clipboard
environment() suffixes missing for numerous services (documents, websites, cognitiveservices, openai, search)
Describe the bug
We would like to use environment() to generate the correct DNS zone names in our Bicep across zones. Right now we'd need to have three options for each service and then parameterize based on Azure Global/China/Govt.
(https://learn.microsoft.com/en-us/azure/private-link/private-endpoint-dns#azure-services-dns-zone-configuration)
To Reproduce
https://learn.microsoft.com/en-us/azure/azure-resource-manager/bicep/bicep-functions-deployment#example-1
You can see these replicated in the Bicep extension.
Additional context
Related issues:
- https://github.com/Azure/bicep/issues/9839
- https://github.com/Azure/bicep/issues/2999
- https://github.com/Azure/bicep/issues/4449
Just want to emphasize per https://github.com/Azure/bicep/issues/9839#issue-1583305101 these DNS zone names are sometimes present and incorrect :(
Including a reference to the "endpoints" API which is similar, but not the same https://management.azure.com/metadata/endpoints?api-version=2022-09-01
Our ideal outcome is to converge on this API and reference it in the environments() function for better long term maintenance.
The ARM team is open to creating a new API Version of /endpoints, but it is not high enough priority for them at this point. They are open to the Deployments driving the new release but this will require creating a swagger spec to properly document this (currently undocumented) API. Once this is done, we can take the dependency on this API and keep it up to date with new endpoints.
Mockup of adding this to the registry:
type environmentType = 'AzureCloud' | 'AzureChinaCloud' | 'AzureUSGovernment'
@export()
@description('Get the graph endpoint for the given environment')
func getGraphEndpoint(environment environmentType | string) string => {
AzureCloud: 'https://graph.windows.net'
AzureChinaCloud: 'https://graph.chinacloudapi.cn'
AzureUSGovernment: 'https://graph.windows.net'
}[environment]
@export()
@description('Get the Portal URL for the given environment')
func getPortalUrl(environment environmentType | string) string => {
AzureCloud: 'https://portal.azure.com'
AzureChinaCloud: 'https://portal.azure.cn'
AzureUSGovernment: 'https://portal.azure.us'
}[environment]
Consumption would look something like this:
import { getGraphEndpoint } from 'br/public:avm/util/environment:0.0.1'
var graphEndpoint = getGraphEndpoint(environment().name)
Adding one more case:
- #14232