1 line
9.1 KiB
JSON
1 line
9.1 KiB
JSON
{"$schema":"https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#","contentVersion":"1.0.0.0","parameters":{"logicAppName":{"type":"String","metadata":{"description":"Name of the logic app."}},"logicAppLocation":{"defaultValue":"[resourceGroup().location]","allowedValues":["eastasia","southeastasia","centralus","eastus","eastus2","westus","northcentralus","southcentralus","northeurope","westeurope","japanwest","japaneast","brazilsouth","australiaeast","australiasoutheast","southindia","centralindia","westindia","canadacentral","canadaeast","westcentralus","westus2","[resourceGroup().location]"],"type":"String","metadata":{"description":"Location of the logic app."}},"office365_Connection_Name":{"defaultValue":"office365","type":"String","metadata":{"description":"Name of the connection."}},"approvals_Connection_Name":{"defaultValue":"approvals","type":"String","metadata":{"description":"Name of the connection."}}},"resources":[{"type":"Microsoft.Logic/workflows","apiVersion":"2016-06-01","name":"[parameters('logicAppName')]","location":"[parameters('logicAppLocation')]","dependsOn":["[resourceId('Microsoft.Web/connections', parameters('office365_Connection_Name'))]","[resourceId('Microsoft.Web/connections', parameters('approvals_Connection_Name'))]"],"properties":{"state":"Disabled","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"},"$authentication":{"defaultValue":{},"type":"SecureObject"}},"triggers":{"manual":{"type":"Request","kind":"Http","inputs":{"schema":{"type":"object","properties":{"groupId":{"type":"string"},"groupName":{"type":"string"},"groupUrl":{"type":"string"},"requestorName":{"type":"string"},"requestorEmail":{"type":"string"}}}}}},"actions":{"Condition":{"actions":{"HTTP_-_Add_Member_to_Group":{"runAfter":{},"type":"Http","inputs":{"method":"POST","uri":"https://graph.microsoft.com/v1.0/groups/@{triggerBody()?['groupId']}/members/$ref","body":{"@@odata.id":"https://graph.microsoft.com/v1.0/users/@{triggerBody()?['requestorEmail']}"},"authentication":{"type":"ActiveDirectoryOAuth","authority":"https://login.microsoft.com","tenant":"@variables('directory_id')","audience":"https://graph.microsoft.com","clientId":"@variables('application_id')","secret":"@variables('secret')"}}},"Send_an_email_(V2)_-_Approved":{"runAfter":{"HTTP_-_Add_Member_to_Group":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"SendEmailV2"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['office365']['connectionId']"}},"method":"post","body":{"To":"@triggerBody()?['requestorEmail']","Subject":"Welcome to private group - @{triggerBody()?['groupName']}","Body":"<p>Hello @{triggerBody()?['requestorName']},<br>\n<br>\nYour request to join the private group - [@{triggerBody()?['groupName']}](@{triggerBody()?['groupUrl']}) is approved.</p>"},"path":"/v2/Mail","authentication":"@parameters('$authentication')"}}},"runAfter":{"Start_and_wait_for_an_approval":["Succeeded"]},"else":{"actions":{"Send_an_email_(V2)_-_Rejected":{"runAfter":{},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"SendEmailV2"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['office365']['connectionId']"}},"method":"post","body":{"To":"@triggerBody()?['requestorEmail']","Subject":"Declined joining private group - @{triggerBody()?['groupName']}","Body":"<p>Hello @{triggerBody()?['requestorName']},<br>\n<br>\nYour request to join the private group - @{triggerBody()?['groupName']} is rejected.</p>"},"path":"/v2/Mail","authentication":"@parameters('$authentication')"}}}},"expression":{"equals":["@body('Start_and_wait_for_an_approval')?['outcome']","Approve"]},"type":"If"},"Initialize_variable_-_application_id":{"runAfter":{},"type":"InitializeVariable","inputs":{"variables":[{"name":"application_id","type":"String"}]}},"Initialize_variable_-_directory_id":{"runAfter":{"Initialize_variable_-_application_id":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"directory_id","type":"String"}]}},"Initialize_variable_-_secret":{"runAfter":{"Initialize_variable_-_directory_id":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"secret","type":"String"}]}},"HTTP_-_Get_group_owners":{"runAfter":{"Initialize_variable_-_secret":["Succeeded"]},"type":"Http","inputs":{"method":"GET","uri":"https://graph.microsoft.com/v1.0/groups/@{triggerBody()?['groupId']}/owners","authentication":{"type":"ActiveDirectoryOAuth","authority":"https://login.microsoft.com","tenant":"@variables('directory_id')","audience":"https://graph.microsoft.com","clientId":"@variables('application_id')","secret":"@variables('secret')"}}},"Parse_JSON":{"runAfter":{"HTTP_-_Get_group_owners":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('HTTP_-_Get_group_owners')","schema":{"type":"object","properties":{"value":{"type":"array","items":{"type":"object","properties":{"@@odata.type":{"type":"string"},"id":{"type":"string"},"displayName":{"type":"string"},"givenName":{"type":"string"},"jobTitle":{},"mail":{"type":"string"},"mobilePhone":{},"officeLocation":{},"preferredLanguage":{"type":["string","null"]},"surname":{"type":"string"},"userPrincipalName":{"type":"string"},"businessPhones":{"type":"array","items":{"type":"string"}}},"required":["@@odata.type","id","businessPhones","displayName","givenName","jobTitle","mail","mobilePhone","officeLocation","preferredLanguage","surname","userPrincipalName"]}},"@@odata.context":{"type":"string"}}}}},"Start_and_wait_for_an_approval":{"runAfter":{"Apply_to_each_-_Compose_approver_email":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"StartAndWaitForAnApproval"}},"type":"ApiConnectionWebhook","inputs":{"host":{"connection":{"name":"@parameters('$connections')['approvals']['connectionId']"}},"body":{"notificationUrl":"@{listCallbackUrl()}","title":"Request to join private group - @{triggerBody()?['groupName']}","assignedTo":"@variables('groupOwners')","details":"Hello,\nYou are receiving this email because you are an owner of private group [@{triggerBody()?['groupName']}](@{triggerBody()?['groupUrl']})\n[@{triggerBody()?['requestorName']}](@{triggerBody()?['requestorEmail']}) has requested to join this group.\n\nPlease take the appropriate action.\nThank you!","itemLink":"@triggerBody()?['groupUrl']","itemLinkDescription":"@triggerBody()?['groupName']","requestor":"@triggerBody()?['requestorEmail']","enableNotifications":true,"enableReassignment":true},"path":"/types/@{encodeURIComponent('Basic')}/subscriptions","authentication":"@parameters('$authentication')"}},"Apply_to_each_-_Compose_approver_email":{"foreach":"@body('Parse_JSON')?['value']","actions":{"Append_to_string_variable":{"runAfter":{},"type":"AppendToStringVariable","inputs":{"name":"groupOwners","value":"@items('Apply_to_each_-_Compose_approver_email')?['mail']"}},"Append_to_string_variable_2":{"runAfter":{"Append_to_string_variable":["Succeeded"]},"type":"AppendToStringVariable","inputs":{"name":"groupOwners","value":";"}}},"runAfter":{"Initialize_variable_groupOwners":["Succeeded"]},"type":"Foreach"},"Initialize_variable_groupOwners":{"runAfter":{"Parse_JSON":["Succeeded"]},"type":"InitializeVariable","inputs":{"variables":[{"name":"groupOwners","type":"String"}]}}}},"parameters":{"$connections":{"value":{"office365":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'office365')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('office365_Connection_Name'))]","connectionName":"[parameters('office365_Connection_Name')]"},"approvals":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'approvals')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('approvals_Connection_Name'))]","connectionName":"[parameters('approvals_Connection_Name')]"}}}},"runtimeConfiguration":{"lifetime":{"unit":"Day","count":30},"collections":{"maximumItemCount":100000},"performanceProfile":{"throttles":{"mode":"Low"}},"retryPolicy":{"type":"Exponential","interval":"PT5M","count":2,"minimumInterval":"PT5M","maximumInterval":"PT1H"}}}},{"type":"Microsoft.Web/connections","apiVersion":"2016-06-01","name":"[parameters('office365_Connection_Name')]","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'office365')]"},"displayName":"[parameters('office365_Connection_Name')]"}},{"type":"Microsoft.Web/connections","apiVersion":"2016-06-01","name":"[parameters('approvals_Connection_Name')]","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'approvals')]"},"displayName":"[parameters('approvals_Connection_Name')]"}}]} |