-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CDN with storage account example (#1030)
* Add CDN with storage account example * Update main.bicep * Update main.bicep * Fix typo and rebuild main.json
- Loading branch information
Showing
2 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
param location string = resourceGroup().location | ||
|
||
var storageAccountName = 'storage${uniqueString(resourceGroup().id)}' | ||
var endPointName = 'endpoint-${uniqueString(resourceGroup().id)}' | ||
var profileName = 'CdnProfile1' | ||
var storageAccountHostName = replace(replace(storageAccount.properties.primaryEndpoints.blob, 'https://', ''), '/', '') | ||
|
||
resource storageAccount 'Microsoft.Storage/storageAccounts@2020-08-01-preview' = { | ||
location: location | ||
name: storageAccountName | ||
kind: 'StorageV2' | ||
sku: { | ||
name: 'Standard_LRS' | ||
} | ||
} | ||
|
||
resource cdnProfile 'Microsoft.Cdn/profiles@2020-04-15' = { | ||
location: location | ||
name: profileName | ||
sku: { | ||
name: 'Standard_Akamai' | ||
} | ||
} | ||
|
||
resource endpoint 'Microsoft.Cdn/profiles/endpoints@2020-04-15' = { | ||
location: location | ||
name: endPointName | ||
properties: { | ||
originHostHeader: storageAccountHostName | ||
isHttpAllowed: true | ||
isHttpsAllowed: true | ||
queryStringCachingBehavior: 'IgnoreQueryString' | ||
contentTypesToCompress: [ | ||
'text/plain' | ||
'text/html' | ||
'text/css' | ||
'application/x-javascript' | ||
'text/javascript' | ||
] | ||
isCompressionEnabled: true | ||
origins: [ | ||
{ | ||
name: 'origin1' | ||
properties: { | ||
hostName: storageAccountHostName | ||
} | ||
} | ||
] | ||
} | ||
} | ||
|
||
output hostName string = endpoint.properties.hostName | ||
output originHostHeader string = endpoint.properties.originHostHeader |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"location": { | ||
"type": "string", | ||
"defaultValue": "[resourceGroup().location]" | ||
} | ||
}, | ||
"functions": [], | ||
"variables": { | ||
"storageAccountName": "[format('storage{0}', uniqueString(resourceGroup().id))]", | ||
"endPointName": "[format('endpoint-{0}', uniqueString(resourceGroup().id))]", | ||
"profileName": "CdnProfile1" | ||
}, | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Storage/storageAccounts", | ||
"apiVersion": "2020-08-01-preview", | ||
"location": "[parameters('location')]", | ||
"name": "[variables('storageAccountName')]", | ||
"kind": "StorageV2", | ||
"sku": { | ||
"name": "Standard_LRS" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Cdn/profiles", | ||
"apiVersion": "2020-04-15", | ||
"location": "[parameters('location')]", | ||
"name": "[variables('profileName')]", | ||
"sku": { | ||
"name": "Standard_Akamai" | ||
} | ||
}, | ||
{ | ||
"type": "Microsoft.Cdn/profiles/endpoints", | ||
"apiVersion": "2020-04-15", | ||
"location": "[parameters('location')]", | ||
"name": "[variables('endPointName')]", | ||
"properties": { | ||
"originHostHeader": "[replace(replace(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob, 'https://', ''), '/', '')]", | ||
"isHttpAllowed": true, | ||
"isHttpsAllowed": true, | ||
"queryStringCachingBehavior": "IgnoreQueryString", | ||
"contentTypesToCompress": [ | ||
"text/plain", | ||
"text/html", | ||
"text/css", | ||
"application/x-javascript", | ||
"text/javascript" | ||
], | ||
"isCompressionEnabled": true, | ||
"origins": [ | ||
{ | ||
"name": "origin1", | ||
"properties": { | ||
"hostName": "[replace(replace(reference(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))).primaryEndpoints.blob, 'https://', ''), '/', '')]" | ||
} | ||
} | ||
] | ||
}, | ||
"dependsOn": [ | ||
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" | ||
] | ||
} | ||
], | ||
"outputs": { | ||
"hostName": { | ||
"type": "string", | ||
"value": "[reference(resourceId('Microsoft.Cdn/profiles/endpoints', split(variables('endPointName'), '/')[0], split(variables('endPointName'), '/')[1])).hostName]" | ||
}, | ||
"originHostHeader": { | ||
"type": "string", | ||
"value": "[reference(resourceId('Microsoft.Cdn/profiles/endpoints', split(variables('endPointName'), '/')[0], split(variables('endPointName'), '/')[1])).originHostHeader]" | ||
} | ||
} | ||
} |