Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions modules/Microsoft.Web/staticSites/.test/min.parameters.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>-az-wss-min-001"
}
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>-az-wss-min-001"
}
}
}
124 changes: 74 additions & 50 deletions modules/Microsoft.Web/staticSites/.test/parameters.json
Original file line number Diff line number Diff line change
@@ -1,50 +1,74 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>-az-wss-x-001"
},
"lock": {
"value": "CanNotDelete"
},
"sku": {
"value": "Standard"
},
"stagingEnvironmentPolicy": {
"value": "Enabled"
},
"allowConfigFileUpdates": {
"value": true
},
"enterpriseGradeCdnStatus": {
"value": "Disabled"
},
"systemAssignedIdentity": {
"value": true
},
"userAssignedIdentities": {
"value": {
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-<<namePrefix>>-az-msi-x-001": {}
}
},
"roleAssignments": {
"value": [
{
"roleDefinitionIdOrName": "Reader",
"principalIds": [
"<<deploymentSpId>>"
]
}
]
},
"privateEndpoints": {
"value": [
{
"subnetResourceId": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints",
"service": "staticSites"
}
]
}
}
}
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"name": {
"value": "<<namePrefix>>-az-wss-x-001"
},
"lock": {
"value": "CanNotDelete"
},
"sku": {
"value": "Standard"
},
"stagingEnvironmentPolicy": {
"value": "Enabled"
},
"allowConfigFileUpdates": {
"value": true
},
"enterpriseGradeCdnStatus": {
"value": "Disabled"
},
"systemAssignedIdentity": {
"value": true
},
"customDomains": {
"value": [
"<<namePrefix>>domain1.domain",
"<<namePrefix>>domain2.domain.domain",
"<<namePrefix>>domain3.domain.domain.domain"
]
},
"appSettings": {
"value": {
"foo": "bar",
"setting": 1
}
},
"functionAppSettings": {
"value": {
"foo": "bar",
"setting": 1
}
},
"userAssignedIdentities": {
"value": {
"/subscriptions/<<subscriptionId>>/resourcegroups/validation-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/adp-<<namePrefix>>-az-msi-x-001": {}
}
},
"roleAssignments": {
"value": [
{
"roleDefinitionIdOrName": "Reader",
"principalIds": [
"<<deploymentSpId>>"
]
}
]
},
"privateEndpoints": {
"value": [
{
"subnetResourceId": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Network/virtualNetworks/adp-<<namePrefix>>-az-vnet-x-001/subnets/<<namePrefix>>-az-subnet-x-005-privateEndpoints",
"service": "staticSites"
}
]
},
"linkedBackend": {
"value": {
"resourceId": "/subscriptions/<<subscriptionId>>/resourceGroups/validation-rg/providers/Microsoft.Web/sites/<<namePrefix>>-az-fa-x-001"
}
}
}
}
33 changes: 33 additions & 0 deletions modules/Microsoft.Web/staticSites/config/deploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@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

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

resource config 'Microsoft.Web/staticSites/config@2022-03-01' = {
#disable-next-line BCP225
name: kind
parent: staticSite
properties: properties
}

@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

37 changes: 37 additions & 0 deletions modules/Microsoft.Web/staticSites/config/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Static Site Config `[Microsoft.Web/staticSites/config]`

This module deploys a Static Site Config.

## Navigation

- [Resource Types](#Resource-Types)
- [Parameters](#Parameters)
- [Outputs](#Outputs)

## 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. |


## 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. |
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"
}
29 changes: 29 additions & 0 deletions modules/Microsoft.Web/staticSites/customDomains/deploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
@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'

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
}
}

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

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

@description('The resource group the static site was deployed into.')
output resourceGroupName string = resourceGroup().name
37 changes: 37 additions & 0 deletions modules/Microsoft.Web/staticSites/customDomains/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# 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)

## Resource Types

| Resource Type | API Version |
| :-- | :-- |
| `Microsoft.Web/staticSites/customDomains` | [2022-03-01](https://docs.microsoft.com/en-us/azure/templates/Microsoft.Web/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 |
| :-- | :-- | :-- | :-- |
| `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. |
4 changes: 4 additions & 0 deletions modules/Microsoft.Web/staticSites/customDomains/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"
}
50 changes: 49 additions & 1 deletion modules/Microsoft.Web/staticSites/deploy.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ 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.')
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,42 @@ 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
}
}

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

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

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'
}
}]

resource staticSite_lock 'Microsoft.Authorization/locks@2017-04-01' = if (!empty(lock)) {
name: '${staticSite.name}-${lock}-lock'
properties: {
Expand Down
33 changes: 33 additions & 0 deletions modules/Microsoft.Web/staticSites/linkedBackends/deploy.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
@description('Requried. The resource id of the backend linked to the static site.')
param backendResourceId string

@description('Optional. The region of the backend linked to the static site.')
param region string = resourceGroup().location

@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. Name of the backend to link to the static site.')
param linkedBackendName string = uniqueString(backendResourceId)

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

resource linkedBackend 'Microsoft.Web/staticSites/linkedBackends@2022-03-01' = {
name: linkedBackendName
parent: staticSite
properties: {
backendResourceId: backendResourceId
region: region
}
}

@description('The name of the static site.')
output name string = linkedBackend.name

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

@description('The resource group the static site was deployed into.')
output resourceGroupName string = resourceGroup().name
Loading