Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
2ff601c
First commit
AlexanderSehr Jul 12, 2022
b7e221f
[Modules] Multi additions to staticSites (#1655)
itpropro Jul 12, 2022
80d675c
Merge branch 'main' into users/itpropro/staticSites
AlexanderSehr Jul 12, 2022
0c03a45
Merge branch 'users/itpropro/staticSites' of https://github.com/Azure…
AlexanderSehr Jul 12, 2022
5d3133b
Update to latest
AlexanderSehr Jul 12, 2022
d42262e
Updated docs
AlexanderSehr Jul 12, 2022
d55c93b
Updated telemetry & docs
AlexanderSehr Jul 12, 2022
4689ff9
Minor fix
AlexanderSehr Jul 12, 2022
c3639d8
Regenerated main readme
AlexanderSehr Jul 12, 2022
e8332fa
Another try
AlexanderSehr Jul 12, 2022
4f3b7b8
Updated files on linux
Jul 12, 2022
7b74e78
Removed custom domain test as it is not operational
AlexanderSehr Jul 12, 2022
0645038
Updated docs
AlexanderSehr Jul 12, 2022
d7fc4ff
Updated test
AlexanderSehr Jul 12, 2022
75a055c
Merged latest main
AlexanderSehr Jul 15, 2022
9556d97
Merged latest main
AlexanderSehr Jul 21, 2022
e2886a0
Update modules/Microsoft.Web/staticSites/config/deploy.bicep
AlexanderSehr Jul 23, 2022
b1f9bf2
Update modules/Microsoft.Web/staticSites/config/deploy.bicep
AlexanderSehr Jul 23, 2022
5b5ac84
Merge branch 'main' into users/itpropro/staticSites
AlexanderSehr Jul 23, 2022
accab41
Updated param files & template
AlexanderSehr Jul 23, 2022
7e6a1b9
Update to latest
AlexanderSehr Jul 23, 2022
976bd48
Update to latest
AlexanderSehr Aug 17, 2022
d13fbca
Merge branch 'main' into users/itpropro/staticSites
AlexanderSehr Sep 2, 2022
41cc52f
Updated ReadMe
AlexanderSehr Sep 2, 2022
ba5b202
Resolved conflict
AlexanderSehr Sep 27, 2022
caa3e86
Updated test
AlexanderSehr Sep 27, 2022
372fd69
Updated readme
AlexanderSehr Sep 27, 2022
052f854
Update modules/Microsoft.Web/staticSites/customDomains/deploy.bicep
AlexanderSehr Sep 28, 2022
44e9795
Update modules/Microsoft.Web/staticSites/customDomains/deploy.bicep
AlexanderSehr Sep 28, 2022
e8c5b5f
Update modules/Microsoft.Web/staticSites/customDomains/deploy.bicep
AlexanderSehr Sep 28, 2022
7a3b743
Update modules/Microsoft.Web/staticSites/linkedBackends/deploy.bicep
AlexanderSehr Sep 28, 2022
a923adf
Update modules/Microsoft.Web/staticSites/linkedBackends/deploy.bicep
AlexanderSehr Sep 28, 2022
822dcaf
Update modules/Microsoft.Web/staticSites/linkedBackends/deploy.bicep
AlexanderSehr Sep 28, 2022
5e89271
Update modules/Microsoft.Web/staticSites/linkedBackends/deploy.bicep
AlexanderSehr Sep 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ param virtualNetworkName string
@description('Required. The name of the Managed Identity to create.')
param managedIdentityName string

@description('Required. The name of the Function App to create.')
param siteName string

@description('Required. The name of the Server Farm to create.')
param serverFarmName string

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2022-01-01' = {
name: virtualNetworkName
location: location
Expand Down Expand Up @@ -48,6 +54,28 @@ resource managedIdentity 'Microsoft.ManagedIdentity/userAssignedIdentities@2018-
location: location
}

resource serverFarm 'Microsoft.Web/serverfarms@2022-03-01' = {
name: serverFarmName
location: location
sku: {
name: 'S1'
tier: 'Standard'
size: 'S1'
family: 'S'
capacity: 1
}
properties: {}
}

resource functionApp 'Microsoft.Web/sites@2022-03-01' = {
name: siteName
location: location
kind: 'functionapp'
properties: {
serverFarmId: serverFarm.id
}
}

@description('The resource ID of the created Virtual Network Subnet.')
output subnetResourceId string = virtualNetwork.properties.subnets[0].id

Expand All @@ -57,5 +85,8 @@ output managedIdentityPrincipalId string = managedIdentity.properties.principalI
@description('The resource ID of the created Managed Identity.')
output managedIdentityResourceId string = managedIdentity.id

@description('The resource ID of the created private DNS zone.')
@description('The resource ID of the created Private DNS zone.')
output privateDNSZoneResourceId string = privateDNSZone.id

@description('The resource ID of the created Function App.')
output siteResourceId string = functionApp.id
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ module resourceGroupResources 'dependencies.bicep' = {
params: {
virtualNetworkName: 'dep-<<namePrefix>>-vnet-${serviceShort}'
managedIdentityName: 'dep-<<namePrefix>>-msi-${serviceShort}'
siteName: 'dep-<<namePrefix>>-fa-${serviceShort}'
serverFarmName: 'dep-<<namePrefix>>-sf-${serviceShort}'
}
}

Expand Down Expand Up @@ -70,5 +72,16 @@ module testDeployment '../../deploy.bicep' = {
userAssignedIdentities: {
'${resourceGroupResources.outputs.managedIdentityResourceId}': {}
}
appSettings: {
foo: 'bar'
setting: 1
}
functionAppSettings: {
foo: 'bar'
setting: 1
}
linkedBackend: {
resourceId: resourceGroupResources.outputs.siteResourceId
}
}
}
50 changes: 50 additions & 0 deletions modules/Microsoft.Web/staticSites/config/deploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
@allowed([
'appsettings'
'functionappsettings'
])
@description('Required. Type of settings to apply.')
param kind string

@description('Required. App settings.')
param properties object

@description('Conditional. The name of the parent Static Web App. Required if the template is used in a standalone deployment.')
param staticSiteName string

@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).')
param enableDefaultTelemetry bool = true

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

resource staticSite 'Microsoft.Web/staticSites@2022-03-01' existing = {
name: staticSiteName
}

resource config 'Microsoft.Web/staticSites/config@2022-03-01' = {
#disable-next-line BCP225 // Disables incorrect error that `name` cannot be determined at compile time.
name: kind
parent: staticSite
properties: properties
}

resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}'
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
}
}
}

@description('The name of the config.')
output name string = config.name

@description('The resource ID of the config.')
output resourceId string = config.id

@description('The name of the resource group the config was created in.')
output resourceGroupName string = resourceGroup().name
51 changes: 51 additions & 0 deletions modules/Microsoft.Web/staticSites/config/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Static Site Config `[Microsoft.Web/staticSites/config]`

This module deploys a Static Site Config.

## Navigation

- [Resource Types](#Resource-Types)
- [Parameters](#Parameters)
- [Outputs](#Outputs)
- [Cross-referenced modules](#Cross-referenced-modules)

## Resource Types

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Web/staticSites/config` | [2022-03-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Web/staticSites/config) |

## Parameters

**Required parameters**

| Parameter Name | Type | Allowed Values | Description |
| :-- | :-- | :-- | :-- |
| `kind` | string | `[appsettings, functionappsettings]` | Type of settings to apply. |
| `properties` | object | | App settings. |

**Conditional parameters**

| Parameter Name | Type | Description |
| :-- | :-- | :-- |
| `staticSiteName` | string | The name of the parent Static Web App. Required if the template is used in a standalone deployment. |

**Optional parameters**

| Parameter Name | Type | Default Value | Description |
| :-- | :-- | :-- | :-- |
| `enableDefaultTelemetry` | bool | `True` | Enable telemetry via the Customer Usage Attribution ID (GUID). |
| `location` | string | `[resourceGroup().location]` | Location for all resources. |


## Outputs

| Output Name | Type | Description |
| :-- | :-- | :-- |
| `name` | string | The name of the config. |
| `resourceGroupName` | string | The name of the resource group the config was created in. |
| `resourceId` | string | The resource ID of the config. |

## Cross-referenced modules

_None_
4 changes: 4 additions & 0 deletions modules/Microsoft.Web/staticSites/config/version.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.6"
}
47 changes: 47 additions & 0 deletions modules/Microsoft.Web/staticSites/customDomains/deploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
@description('Conditional. The custom domain name. Required if the template is used in a standalone deployment.')
param name string

@description('Conditional. The name of the parent Static Web App. Required if the template is used in a standalone deployment.')
param staticSiteName string

@description('Optional. Validation method for adding a custom domain.')
param validationMethod string = 'cname-delegation'

@description('Optional. Enable telemetry via the Customer Usage Attribution ID (GUID).')
param enableDefaultTelemetry bool = true

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

resource staticSite 'Microsoft.Web/staticSites@2022-03-01' existing = {
name: staticSiteName
}

resource customDomain 'Microsoft.Web/staticSites/customDomains@2022-03-01' = {
name: name
parent: staticSite
properties: {
validationMethod: validationMethod
}
}

resource defaultTelemetry 'Microsoft.Resources/deployments@2021-04-01' = if (enableDefaultTelemetry) {
name: 'pid-47ed15a6-730a-4827-bcb4-0fd963ffbd82-${uniqueString(deployment().name, location)}'
properties: {
mode: 'Incremental'
template: {
'$schema': 'https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#'
contentVersion: '1.0.0.0'
resources: []
}
}
}

@description('The name of the static site custom domain.')
output name string = customDomain.name

@description('The resource ID of the static site custom domain.')
output resourceId string = customDomain.id

@description('The resource group the static site custom domain was deployed into.')
output resourceGroupName string = resourceGroup().name
46 changes: 46 additions & 0 deletions modules/Microsoft.Web/staticSites/customDomains/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Static Site Custom Domain `[Microsoft.Web/staticSites/customDomains]`

This module deploys a Custom Domain into a Static Site.

## Navigation

- [Resource Types](#Resource-Types)
- [Parameters](#Parameters)
- [Outputs](#Outputs)
- [Cross-referenced modules](#Cross-referenced-modules)

## Resource Types

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Web/staticSites/customDomains` | [2022-03-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Web/2022-03-01/staticSites/customDomains) |

## Parameters

**Conditional parameters**

| Parameter Name | Type | Description |
| :-- | :-- | :-- |
| `name` | string | The custom domain name. Required if the template is used in a standalone deployment. |
| `staticSiteName` | string | The name of the parent Static Web App. Required if the template is used in a standalone deployment. |

**Optional parameters**

| Parameter Name | Type | Default Value | Description |
| :-- | :-- | :-- | :-- |
| `enableDefaultTelemetry` | bool | `True` | Enable telemetry via the Customer Usage Attribution ID (GUID). |
| `location` | string | `[resourceGroup().location]` | Location for all resources. |
| `validationMethod` | string | `'cname-delegation'` | Validation method for adding a custom domain. |


## Outputs

| Output Name | Type | Description |
| :-- | :-- | :-- |
| `name` | string | The name of the static site. |
| `resourceGroupName` | string | The resource group the static site was deployed into. |
| `resourceId` | string | The resource ID of the static site. |

## Cross-referenced modules

_None_
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"$schema": "https://raw.githubusercontent.com/dotnet/Nerdbank.GitVersioning/master/src/NerdBank.GitVersioning/version.schema.json",
"version": "0.6"
}
56 changes: 54 additions & 2 deletions modules/Microsoft.Web/staticSites/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ param name string
@description('Optional. Type of static site to deploy.')
param sku string = 'Free'

@description('Optional. If config file is locked for this static web app.')
@description('Optional. False if config file is locked for this static web app; otherwise, true.')
param allowConfigFileUpdates bool = true

@description('Optional. Location to deploy static site. The following locations are supported: CentralUS, EastUS2, EastAsia, WestEurope, WestUS2.')
@description('Optional. Location for all resources.')
param location string = resourceGroup().location

@allowed([
Expand Down Expand Up @@ -77,6 +77,18 @@ param enableDefaultTelemetry bool = true
@description('Optional. Array of role assignment objects that contain the \'roleDefinitionIdOrName\' and \'principalId\' to define RBAC role assignments on this resource. In the roleDefinitionIdOrName attribute, you can provide either the display name of the role definition, or its fully qualified ID in the following format: \'/providers/Microsoft.Authorization/roleDefinitions/c2f4ef07-c644-48eb-af81-4b1b4947fb11\'.')
param roleAssignments array = []

@description('Optional. Object with "resourceId" and "location" of the a user defined function app.')
param linkedBackend object = {}

@description('Optional. Static site app settings.')
param appSettings object = {}

@description('Optional. Function app settings.')
param functionAppSettings object = {}

@description('Optional. The custom domains associated with this static site. The deployment will fail as long as the validation records are not present.')
param customDomains array = []

var enableReferencedModulesTelemetry = false

var identityType = systemAssignedIdentity ? (!empty(userAssignedIdentities) ? 'SystemAssigned,UserAssigned' : 'SystemAssigned') : (!empty(userAssignedIdentities) ? 'UserAssigned' : 'None')
Expand Down Expand Up @@ -120,6 +132,46 @@ resource staticSite 'Microsoft.Web/staticSites@2021-03-01' = {
}
}

module staticSite_linkedBackend 'linkedBackends/deploy.bicep' = if (!empty(linkedBackend)) {
name: '${uniqueString(deployment().name, location)}-StaticSite-UserDefinedFunction'
params: {
staticSiteName: staticSite.name
backendResourceId: linkedBackend.resourceId
region: contains(linkedBackend, 'location') ? linkedBackend.location : location
enableDefaultTelemetry: enableReferencedModulesTelemetry
}
}

module staticSite_appSettings 'config/deploy.bicep' = if (!empty(appSettings)) {
name: '${uniqueString(deployment().name, location)}-StaticSite-appSettings'
params: {
kind: 'appsettings'
staticSiteName: staticSite.name
properties: appSettings
enableDefaultTelemetry: enableReferencedModulesTelemetry
}
}

module staticSite_functionAppSettings 'config/deploy.bicep' = if (!empty(functionAppSettings)) {
name: '${uniqueString(deployment().name, location)}-StaticSite-functionAppSettings'
params: {
kind: 'functionappsettings'
staticSiteName: staticSite.name
properties: functionAppSettings
enableDefaultTelemetry: enableReferencedModulesTelemetry
}
}

module staticSite_customDomains 'customDomains/deploy.bicep' = [for (customDomain, index) in customDomains: {
name: '${uniqueString(deployment().name, location)}-StaticSite-customDomains-${index}'
params: {
name: customDomain
staticSiteName: staticSite.name
validationMethod: indexOf(customDomain, '.') == lastIndexOf(customDomain, '.') ? 'dns-txt-token' : 'cname-delegation'
enableDefaultTelemetry: enableReferencedModulesTelemetry
}
}]

resource staticSite_lock 'Microsoft.Authorization/locks@2017-04-01' = if (!empty(lock)) {
name: '${staticSite.name}-${lock}-lock'
properties: {
Expand Down
Loading