Skip to content

Instantly share code, notes, and snippets.

@ljtill
Last active September 28, 2021 10:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljtill/af025397631c01d9c220271415583c67 to your computer and use it in GitHub Desktop.
Save ljtill/af025397631c01d9c220271415583c67 to your computer and use it in GitHub Desktop.
Provides the ability to deploy Azure Functions via Bicep
// ------
// Scopes
// ------
targetScope = 'subscription'
// ---------
// Modules
// ---------
module resources './resources.bicep' = {
name: 'Microsoft.Service.Interface.Resources.${count}'
scope: subscription()
params: {
name: name
location: location
tags: tags
}
}
module storage './storage.bicep' = {
name: 'Microsoft.Service.Interface.Storage.${count}'
scope: resourceGroup(name)
params: {
name: name
location: location
tags: tags
}
dependsOn: [
resources
]
}
module web './web.bicep' = {
name: 'Microsoft.Service.Interface.Web.${count}'
scope: resourceGroup(name)
params: {
name: name
location: location
tags: tags
storage: storage.outputs.storage
insights: insights
}
dependsOn: [
storage
]
}
// ---------
// Parameters
// ---------
param count int
param tags object
param location string
param name string
param insights object
// ------
// Scopes
// ------
targetScope = 'subscription'
// ---------
// Resources
// ---------
resource resource_group 'Microsoft.Resources/resourceGroups@2020-06-01' = {
name: name
location: location
properties: {}
tags: tags
}
// ---------
// Parameters
// ---------
param name string
param location string
param tags object
// ------
// Scopes
// ------
targetScope = 'resourceGroup'
// ---------
// Resources
// ---------
resource storage_account 'Microsoft.Storage/storageAccounts@2021-02-01' = {
name: name
location: location
sku: {
name: 'Standard_LRS'
tier: 'Standard'
}
properties: {}
kind: 'Storage'
tags: tags
}
// ---------
// Parameters
// ---------
param name string
param location string
param tags object
// ---------
// Outputs
// ---------
output storage object = storage_account
// ------
// Scopes
// ------
targetScope = 'resourceGroup'
// ---------
// Resources
// ---------
resource server_farm 'Microsoft.Web/serverfarms@2020-12-01' = {
name: name
location: location
kind: 'functionapp'
sku: {
name: 'Y1'
tier: 'Dynamic'
size: 'Y1'
family: 'Y'
capacity: 0
}
properties: {
reserved: true
}
tags: tags
}
resource site 'Microsoft.Web/sites@2020-12-01' = {
name: name
location: location
kind: 'functionapp,linux'
properties: {
serverFarmId: server_farm.id
httpsOnly: true
siteConfig: {
appSettings: [
{
name: 'APPINSIGHTS_INSTRUMENTATIONKEY'
value: insights.properties.InstrumentationKey
}
{
name: 'AzureWebJobsStorage'
value: concat('DefaultEndpointsProtocol=https;AccountName=', name, ';AccountKey=', listKeys(storage.resourceId, '2021-02-01').keys[0].value, ';EndpointSuffix=core.windows.net')
}
{
name: 'FUNCTIONS_EXTENSION_VERSION'
value: '~3'
}
{
name: 'FUNCTIONS_WORKER_RUNTIME'
value: 'dotnet-isolated'
}
]
linuxFxVersion: 'dotnet|5.0'
}
}
tags: tags
}
resource diagnostics 'microsoft.insights/diagnosticSettings@2017-05-01-preview' = {
scope: site
name: 'default'
properties: {
workspaceId: insights.properties.workspaceResourceId
metrics: [
{
category: 'AllMetrics'
enabled: true
retentionPolicy: {
days: 0
enabled: false
}
}
]
logs: [
{
category: 'FunctionAppLogs'
enabled: true
}
]
}
}
// ---------
// Parameters
// ---------
param name string
param location string
param tags object
param storage object
param insights object
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment