{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"storageAccounts_dotnet_mailintegration_name": {
"defaultValue": null,
"type": "String"
},
"serviceplans_dotnet_mailintegration_name": {
"defaultValue": "mailintegration",
"type": "String"
},
"sites_dotnet_mailintegration_name": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_shard_map_manager_connection_string": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_tenants_connection_string": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_shard_user_name": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_shard_password": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_documents_storage_account": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_documents_storage_base_address": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_documents_storage_account_key": {
"defaultValue": null,
"type": "String"
},
"sites_dotnet_mailintegration_table_storage_name": {
"defaultValue": null,
"type": "String"
},
"insights_dotnet_mailintegration_name": {
"defaultValue": null,
"type": "String"
},
"workflows_inboundeventreader_name": {
"defaultValue": null,
"type": "String"
},
"workflows_inboundmailreader_name": {
"defaultValue": null,
"type": "String"
},
"connections_office365_name": {
"defaultValue": null,
"type": "String"
},
"connections_office365_emailaccount_name": {
"defaultValue": null,
"type": "String"
},
"connections_blobstorage_name": {
"type": "string",
"defaultValue": null
},
"connections_blobstorage_storageaccount_name": {
"type": "string",
"defaultValue": null
},
"resource_group_Location": {
"type": "string",
"defaultValue": "uksouth"
}
},
"variables": {
"storageAccountId": "[resourceId('Microsoft.Storage/storageAccounts', parameters('connections_blobstorage_storageaccount_name'))]"
},
"resources": [
{
"apiVersion": "2019-06-01",
"kind": "StorageV2",
"location": "[parameters('resource_group_Location')]",
"name": "[parameters('storageAccounts_dotnet_mailintegration_name')]",
"properties": {
"supportsHttpsTrafficOnly": true,
"encryption": {
"services": {
"blob": {
"keyType": "Account",
"enabled": true
}
},
"keySource": "Microsoft.Storage"
},
"accessTier": "Hot"
},
"sku": {
"name": "Standard_LRS",
"tier": "Standard"
},
"type": "Microsoft.Storage/storageAccounts"
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2018-02-01",
"name": "[parameters('serviceplans_dotnet_mailintegration_name')]",
"location": "[parameters('resource_group_Location')]",
"sku": {
"name": "B1",
"tier": "Basic",
"size": "B1",
"family": "B",
"capacity": 1
},
"kind": "linux",
"properties": {
"perSiteScaling": false,
"maximumElasticWorkerCount": 1,
"isSpot": false,
"reserved": true,
"isXenon": false,
"hyperV": false,
"targetWorkerCount": 0,
"targetWorkerSizeId": 0
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2018-11-01",
"name": "[parameters('sites_dotnet_mailintegration_name')]",
"location": "[parameters('resource_group_Location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', parameters('serviceplans_dotnet_mailintegration_name'))]"
],
"kind": "functionapp,linux",
"properties": {
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('serviceplans_dotnet_mailintegration_name'))]",
"siteConfig": {
"appSettings": [
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~3"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "dotnet"
},
{
"name": "WEBSITE_ENABLE_SYNC_UPDATE_SITE",
"value": "true"
},
{
"name": "WEBSITES_ENABLE_APP_SERVICE_STORAGE",
"value": "true"
},
{
"name": "SourceItemsStorageContainer",
"value": "sourceitems"
},
{
"name": "CalendarStorageContainer",
"value": "calendaritemstoprocess"
},
{
"name": "EmailStorageContainer",
"value": "mailitemstoprocess"
},
{
"name": "ProcessedFailedItemsContainer",
"value": "processedfailed"
},
{
"name": "DocumentsStorageAccount",
"value": "[parameters('sites_dotnet_mailintegration_documents_storage_account')]"
},
{
"name": "DocumentsStorageBaseAddress",
"value": "[parameters('sites_dotnet_mailintegration_documents_storage_base_address')]"
},
{
"name": "DocumentsStorageAccountKey",
"value": "[parameters('sites_dotnet_mailintegration_documents_storage_account_key')]"
},
{
"name": "TableStorageName",
"value": "[parameters('sites_dotnet_mailintegration_table_storage_name')]"
},
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(resourceId(resourceGroup().name, 'microsoft.insights/components/', parameters('insights_dotnet_mailintegration_name')), '2015-05-01').InstrumentationKey]"
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[concat('InstrumentationKey=', reference(resourceId(resourceGroup().name, 'microsoft.insights/components/', parameters('insights_dotnet_mailintegration_name')), '2015-05-01').InstrumentationKey)]"
},
{
"name": "ShardMapManagerDatabaseConnectionString",
"value": "[parameters('sites_dotnet_mailintegration_shard_map_manager_connection_string')]"
},
{
"name": "TenantsDatabaseConnectionString",
"value": "[parameters('sites_dotnet_mailintegration_tenants_connection_string')]"
},
{
"name": "ShardUsername",
"value": "[parameters('sites_dotnet_mailintegration_shard_user_name')]"
},
{
"name": "ShardPassword",
"value": "[parameters('sites_dotnet_mailintegration_shard_password')]"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=', parameters('storageAccounts_dotnet_mailintegration_name'),';AccountKey=', listKeys(variables('storageAccountId'),'2015-05-01-preview').key1, ';BlobEndpoint=https://', parameters('storageAccounts_dotnet_mailintegration_name'), '.blob.core.windows.net/;TableEndpoint=https://',parameters('storageAccounts_dotnet_mailintegration_name'),'.table.core.windows.net/;QueueEndpoint=https://', parameters('storageAccounts_dotnet_mailintegration_name'), '.queue.core.windows.net/;FileEndpoint=https://',parameters('storageAccounts_dotnet_mailintegration_name'),'.file.core.windows.net/')]"
}
]
}
}
},
{
"type": "microsoft.insights/components",
"apiVersion": "2018-05-01-preview",
"name": "[parameters('insights_dotnet_mailintegration_name')]",
"location": "[parameters('resource_group_Location')]",
"kind": "web",
"properties": {
"Application_Type": "web",
"RetentionInDays": 90,
"publicNetworkAccessForIngestion": "Enabled",
"publicNetworkAccessForQuery": "Enabled"
}
},
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('workflows_inboundeventreader_name')]",
"location": "[parameters('resource_group_Location')]",
"properties": {
"state": "Enabled",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_an_event_is_added,_updated_or_deleted_(V3)": {
"splitOn": "@triggerBody()?['value']",
"type": "ApiConnectionNotification",
"inputs": {
"fetch": {
"method": "get",
"pathTemplate": {
"parameters": {
"table": "@{encodeURIComponent(encodeURIComponent('AAMkAGQzMDk5YmEyLTExMDgtNDc0Mi1hYzcwLWQ2NTI1OWE0N2Q2MwBGAAAAAABb3A04EHa3Q4MW86I7MhuCBwB7l-23qyrcS4xFXZTEcZjDAAAAAAEGAAB7l-23qyrcS4xFXZTEcZjDAAAAfTWmAAA='))}"
},
"template": "/datasets/calendars/v3/tables/{table}/onchangeditems"
},
"queries": {
"incomingDays": 300,
"pastDays": 30
}
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"subscribe": {
"body": {
"NotificationUrl": "@{listCallbackUrl()}"
},
"method": "post",
"pathTemplate": {
"parameters": {
"table": "@{encodeURIComponent(encodeURIComponent('AAMkAGQzMDk5YmEyLTExMDgtNDc0Mi1hYzcwLWQ2NTI1OWE0N2Q2MwBGAAAAAABb3A04EHa3Q4MW86I7MhuCBwB7l-23qyrcS4xFXZTEcZjDAAAAAAEGAAB7l-23qyrcS4xFXZTEcZjDAAAAfTWmAAA='))}"
},
"template": "/{table}/GraphEventSubscriptionPoke/$subscriptions"
},
"queries": {
"incomingDays": 300,
"pastDays": 30
}
}
}
}
},
"actions": {
"Create_Blob": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"body": "\n@{triggerBody()?['subject']}\n@{triggerBody()?['start']}\n@{triggerBody()?['end']}\n@{triggerBody()?['location']}\n@{triggerBody()?['organizer']}\n@{triggerBody()?['ActionType']}\n@{triggerBody()?['requiredAttendees']}\n@{triggerBody()?['optionalAttendees']}\n@{triggerBody()?['id']}\n\n",
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/files",
"queries": {
"folderPath": "/calendaritemstoprocess",
"name": "@triggerBody()?['id']",
"queryParametersSingleEncoded": true
}
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_blobstorage_name'))]",
"connectionName": "[parameters('connections_blobstorage_name')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location , '/managedApis/azureblob')]"
},
"office365": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_office365_name'))]",
"connectionName": "[parameters('connections_office365_name')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('connections_blobstorage_name'))]",
"[resourceId('Microsoft.Web/connections', parameters('connections_office365_name'))]"
]
},
{
"type": "Microsoft.Logic/workflows",
"apiVersion": "2017-07-01",
"name": "[parameters('workflows_inboundmailreader_name')]",
"location": "[parameters('resource_group_Location')]",
"properties": {
"state": "Enabled",
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"When_a_new_email_arrives_(V3)": {
"splitOn": "@triggerBody()?['value']",
"type": "ApiConnectionNotification",
"inputs": {
"fetch": {
"method": "get",
"pathTemplate": {
"template": "/v3/Mail/OnNewEmail"
},
"queries": {
"fetchOnlyWithAttachment": false,
"folderPath": "Inbox",
"importance": "Any",
"includeAttachments": false
}
},
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"subscribe": {
"body": {
"NotificationUrl": "@{listCallbackUrl()}"
},
"method": "post",
"pathTemplate": {
"template": "/GraphMailSubscriptionPoke/$subscriptions"
},
"queries": {
"fetchOnlyWithAttachment": false,
"folderPath": "Inbox",
"importance": "Any"
}
}
}
}
},
"actions": {
"Create_blob_for_email": {
"runAfter": {},
"type": "ApiConnection",
"inputs": {
"body": "\n@{triggerBody()?['toRecipients']}\n@{triggerBody()?['ccRecipients']}\n@{triggerBody()?['from']}\n@{triggerBody()?['subject']}\n\n",
"host": {
"connection": {
"name": "@parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/files",
"queries": {
"folderPath": "/mailitemstoprocess",
"name": "@triggerBody()?['id']",
"queryParametersSingleEncoded": true
}
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
},
"Delete_email_(V2)": {
"runAfter": {
"Create_blob_for_email": [
"Succeeded"
]
},
"type": "ApiConnection",
"inputs": {
"host": {
"connection": {
"name": "@parameters('$connections')['office365']['connectionId']"
}
},
"method": "delete",
"path": "/codeless/v1.0/me/messages/@{encodeURIComponent(triggerBody()?['id'])}"
}
}
},
"outputs": {}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_blobstorage_name'))]",
"connectionName": "[parameters('connections_blobstorage_name')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location , '/managedApis/azureblob')]"
},
"office365": {
"connectionId": "[resourceId('Microsoft.Web/connections', parameters('connections_office365_name'))]",
"connectionName": "[parameters('connections_office365_name')]",
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location, '/managedApis/office365')]"
}
}
}
}
},
"dependsOn": [
"[resourceId('Microsoft.Web/connections', parameters('connections_blobstorage_name'))]",
"[resourceId('Microsoft.Web/connections', parameters('connections_office365_name'))]"
]
},
{
"type": "Microsoft.Web/connections",
"name": "[parameters('connections_blobstorage_name')]",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"scale": null,
"properties": {
"displayName": "[parameters('connections_blobstorage_name')]",
"parameterValues": {
"accountName": "[parameters('connections_blobstorage_storageaccount_name')]",
"accessKey": "[listKeys(variables('storageAccountId'),'2015-05-01-preview').key1]"
},
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location , '/managedApis/azureblob')]"
}
}
},
{
"name": "[parameters('connections_office365_name')]",
"type": "Microsoft.Web/connections",
"apiVersion": "2016-06-01",
"location": "[resourceGroup().location]",
"tags": {
},
"properties": {
"displayName": "[parameters('connections_office365_emailaccount_name')]",
"parameterValues": {
},
"customParameterValues": {
},
"nonSecretParameterValues": {
},
"api": {
"id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', resourceGroup().location ,'/managedApis/office365')]"
}
}
}
]
}