Share via

Enable CDN MANAGED Certificate using Bicep

kade 11 Reputation points
2022-01-05T14:51:23.89+00:00

I have been trying to enable CDN MANAGED Certificate using Bicep but I am not able to get it to work.
I used the PowerShell command: Enable-AzCdnCustomDomainHttps but it only enable the Default CDN Certificate but not the Managed one.

The certificate that I am using for the CDN is already created in different RG.

param profileName string = 'testresearchcdn'

@Allowed([
'Standard_Verizon'
'Premium_Verizon'
'Custom_Verizon'
'Standard_Akamai'
'Standard_ChinaCdn'
'Standard_Microsoft'
'Premium_ChinaCdn'
'Standard_AzureFrontDoor'
'Premium_AzureFrontDoor'
'Standard_955BandWidth_ChinaCdn'
'Standard_AvgBandWidth_ChinaCdn'
'StandardPlus_ChinaCdn'
'StandardPlus_955BandWidth_ChinaCdn'
'StandardPlus_AvgBandWidth_ChinaCdn'
])
param sku string = 'Standard_Microsoft'

param endpointName string = 'testresearchcdn'

@description('Whether the HTTP traffic is allowed.')
param isHttpAllowed bool = true

@description('Whether the HTTPS traffic is allowed.')
param isHttpsAllowed bool = true

@description('Query string caching behavior.')
@Allowed([
'IgnoreQueryString'
'BypassCaching'
'UseQueryString'
])
param queryStringCachingBehavior string = 'IgnoreQueryString'

@description('Content type that is compressed.')
param contentTypesToCompress array = [
'text/plain'
'text/html'
'text/css'
'application/x-javascript'
'text/javascript'
]

@description('Whether the compression is enabled')
param isCompressionEnabled bool = true

@description('Location for all resources.')
param location string = 'global'

resource testresearchcdn 'Microsoft.Cdn/profiles@2020-09-01' = {
name: profileName
location: location
properties: {}
sku: {
name: sku
}
}

resource Microsoft_Cdn_profiles_endpoints_testresearchcdn 'Microsoft.Cdn/profiles/endpoints@2020-09-01' = {
name: endpointName
parent: testresearchcdn
location: location
properties: {
originHostHeader: 'testresearchcdn.blob.core.windows.net'
isHttpAllowed: isHttpAllowed
isHttpsAllowed: isHttpsAllowed
queryStringCachingBehavior: queryStringCachingBehavior
contentTypesToCompress: contentTypesToCompress
isCompressionEnabled: isCompressionEnabled
origins: [
{
name: 'testresearchcdn-blob-core-windows-net'
properties: {
hostName: 'testresearchcdn.blob.core.windows.net'
}
}
]
}

}

resource test_researchcdn_example_com 'Microsoft.Cdn/profiles/endpoints/customDomains@2016-04-02' = {
name: 'test-researchcdn-example-com'
parent: Microsoft_Cdn_profiles_endpoints_testresearchcdn
properties: {
hostName: 'test-researchcdn-example-com'
}

}

resource example_wildcard_2019 'Microsoft.Cdn/profiles/secrets@2020-09-01' = {
name: 'KeyVault1'
parent: testresearchcdn
properties: {
parameters: {
type: 'CustomerCertificate'
certificateAuthority: 'OU=http://certs.godaddy.com/repository/'
secretSource: {
id: '/subscriptions/xxxxxxxxxxxxxxxxxxxxxx/resourceGroups/BIBProdPSEARG01/providers/Microsoft.KeyVault/vaults/xxxxxxxx/certificates/certName/xxxxxxxxxxxxxxxxxxxxxxxxxx'
}
secretVersion: ''
subjectAlternativeNames: [
'*.example.com'
'example.com'
]
useLatestVersion: false
}
}
dependsOn: [
test_researchcdn_example_com
]

}

Azure Content Delivery Network

Your answer

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