bicep icon indicating copy to clipboard operation
bicep copied to clipboard

environment() suffixes missing for numerous services (documents, websites, cognitiveservices, openai, search)

Open pamelafox opened this issue 2 years ago • 5 comments

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

pamelafox avatar Nov 16 '23 23:11 pamelafox

Just want to emphasize per https://github.com/Azure/bicep/issues/9839#issue-1583305101 these DNS zone names are sometimes present and incorrect :(

ryancole0 avatar Feb 21 '24 11:02 ryancole0

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.

alex-frankel avatar Feb 29 '24 17:02 alex-frankel

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.

alex-frankel avatar Apr 01 '24 17:04 alex-frankel

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)

anthony-c-martin avatar Apr 01 '24 22:04 anthony-c-martin

Adding one more case:

  • #14232

alex-frankel avatar Jun 06 '24 15:06 alex-frankel