Skip to content

Instantly share code, notes, and snippets.

@AlexanderHolmeset
Created December 16, 2024 12:36
Show Gist options
  • Save AlexanderHolmeset/b4aa0cf0a54fd94808250356b7611053 to your computer and use it in GitHub Desktop.
Save AlexanderHolmeset/b4aa0cf0a54fd94808250356b7611053 to your computer and use it in GitHub Desktop.
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"contentVersion": "1.0.0.0",
"triggers": {
"Recurrence": {
"type": "Recurrence",
"recurrence": {
"interval": 3,
"frequency": "Month",
"timeZone": "Romance Standard Time"
}
}
},
"actions": {
"HTTP_GET_DeltaLink_Keyvault": {
"type": "Http",
"inputs": {
"uri": "https://nextlink.vault.azure.net/secrets/nextlink/?api-version=7.4",
"method": "GET",
"authentication": {
"type": "ManagedServiceIdentity",
"audience": "https://vault.azure.net"
}
},
"runAfter": {},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
},
"HTTP_Graph_GroupMember_Delta": {
"type": "Http",
"inputs": {
"uri": "@outputs('HTTP_GET_DeltaLink_Keyvault')['body']['value']",
"method": "GET",
"authentication": {
"type": "ManagedServiceIdentity",
"audience": "https://graph.microsoft.com"
}
},
"runAfter": {
"HTTP_GET_DeltaLink_Keyvault": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
},
"HTTP_PUT_DeltaLink_Keyvault": {
"type": "Http",
"inputs": {
"uri": "https://nextlink.vault.azure.net/secrets/nextlink/?api-version=7.4",
"method": "PUT",
"body": {
"value": "@{outputs('HTTP_Graph_GroupMember_Delta')['body']['@odata.deltaLink']}"
},
"authentication": {
"type": "ManagedServiceIdentity",
"audience": "https://vault.azure.net"
}
},
"runAfter": {
"AnyChanges": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
},
"AnyChanges": {
"type": "Compose",
"inputs": "@{outputs('HTTP_Graph_GroupMember_Delta')['body']['value']}1",
"runAfter": {
"HTTP_Graph_GroupMember_Delta": [
"Succeeded"
]
}
},
"Condition": {
"type": "If",
"expression": {
"and": [
{
"not": {
"equals": [
"@outputs('AnyChanges')",
"[]1"
]
}
}
]
},
"actions": {
"For_Each_User": {
"type": "Foreach",
"foreach": "@outputs('HTTP_Graph_GroupMember_Delta')['body']['value'][0]['members@delta']",
"actions": {
"Condition_User_Not_Removed": {
"type": "If",
"expression": {
"equals": [
"@contains(item(), '@removed')",
false
]
},
"actions": {
"HTTP_Graph_User": {
"type": "Http",
"inputs": {
"uri": "https://graph.microsoft.com/v1.0/users/@{items('For_Each_User')['id']}",
"method": "GET",
"authentication": {
"type": "ManagedServiceIdentity",
"audience": "https://graph.microsoft.com"
}
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
},
"HTTP_Graph_Mail": {
"type": "Http",
"inputs": {
"uri": "https://graph.microsoft.com/v1.0/users/[email protected]/sendmail",
"method": "POST",
"body": {
"message": {
"subject": "Velkommen som Copilot-bruker",
"body": {
"contentType": "HTML",
"content": "<p>Hi, welcome as a new Copilot user!</p>"
},
"toRecipients": [
{
"emailAddress": {
"address": "@{outputs('HTTP_Graph_User')['body']['mail']}"
}
}
],
"ccRecipients": [
{
"emailAddress": {
"address": "[email protected]"
}
}
]
},
"saveToSentItems": "true"
},
"authentication": {
"type": "ManagedServiceIdentity",
"audience": "https://graph.microsoft.com"
}
},
"runAfter": {
"HTTP_Graph_User": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
},
"HTTP_Add_Team": {
"type": "Http",
"inputs": {
"uri": "https://graph.microsoft.com/v1.0/groups/93371e79-a81a-478d-8a9d-b8817729aac2/",
"method": "PATCH",
"body": {
"[email protected]": [
"https://graph.microsoft.com/v1.0/directoryObjects/@{items('For_Each_User')['id']}"
]
},
"authentication": {
"type": "ManagedServiceIdentity"
}
},
"runAfter": {
"HTTP_Graph_Mail": [
"SUCCEEDED"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
}
}
},
"else": {
"actions": {}
}
}
}
}
},
"else": {
"actions": {}
},
"runAfter": {
"HTTP_PUT_DeltaLink_Keyvault": [
"Succeeded"
]
}
}
},
"outputs": {},
"parameters": {
"$connections": {
"type": "Object",
"defaultValue": {}
}
}
},
"parameters": {
"$connections": {
"value": {}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment