diff --git a/Sessions/Craig Porteous - Power BI under Source Control/Backup All Power BI Reports to OneDrive.json b/Sessions/Craig Porteous - Power BI under Source Control/Backup All Power BI Reports to OneDrive.json new file mode 100644 index 0000000..c026a63 --- /dev/null +++ b/Sessions/Craig Porteous - Power BI under Source Control/Backup All Power BI Reports to OneDrive.json @@ -0,0 +1 @@ +{"$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."}},"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name":{"defaultValue":"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1","type":"String","metadata":{"description":"Name of the connection."}},"onedriveforbusiness_Connection_Name":{"defaultValue":"onedriveforbusiness","type":"String","metadata":{"description":"Name of the connection."}}},"resources":[{"type":"Microsoft.Logic/workflows","name":"[parameters('logicAppName')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","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":{"Recurrence":{"recurrence":{"frequency":"Day","interval":1},"type":"Recurrence"}},"actions":{"Get_All_Workspaces":{"runAfter":{"Initialize_Workspace_Name_variable":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"GetAllWorkspaces"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']"}},"method":"get","path":"/v1.0/myorg/groups","authentication":"@parameters('$authentication')"}},"Parse_Workspace_JSON":{"runAfter":{"Get_All_Workspaces":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_All_Workspaces')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"@@odata.count":{"type":"integer"},"value":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"isReadOnly":{"type":"boolean"},"isOnDedicatedCapacity":{"type":"boolean"},"name":{"type":"string"}},"required":["id","isReadOnly","isOnDedicatedCapacity","name"]}}}}}},"Apply_to_each_Workspace":{"foreach":"@body('Parse_Workspace_JSON')?['value']","actions":{"Get_all_Reports":{"runAfter":{"Set_Workspace_Name_variable":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"GetAllReports"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']"}},"method":"get","path":"/v1.0/myorg/groups/@{encodeURIComponent(items('Apply_to_each_Workspace')?['id'])}/reports","authentication":"@parameters('$authentication')"}},"Parse_Report_JSON":{"runAfter":{"Get_all_Reports":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_all_Reports')","schema":{"type":"object","properties":{"@@odata.context":{"type":"string"},"value":{"type":"array","items":{"type":"object","properties":{"id":{"type":"string"},"name":{"type":"string"},"webUrl":{"type":"string"},"embedUrl":{"type":"string"},"isOwnedByMe":{"type":"boolean"},"datasetId":{"type":"string"}},"required":["id","name","webUrl","embedUrl","isOwnedByMe","datasetId"]}}}}}},"Apply_to_each_Report":{"foreach":"@body('Parse_Report_JSON')?['value']","actions":{"Export_Report":{"runAfter":{},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"ExportReport"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']"}},"method":"get","path":"/v1.0/myorg/groups/@{encodeURIComponent(items('Apply_to_each_Workspace')?['id'])}/reports/@{encodeURIComponent(items('Apply_to_each_Report')?['id'])}/Export","authentication":"@parameters('$authentication')"}},"Create_Power_BI_file_in_OneDrive":{"runAfter":{"Export_Report":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"CreateFile"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['onedriveforbusiness']['connectionId']"}},"method":"post","body":"@body('Export_Report')","path":"/datasets/default/files","queries":{"folderPath":"PowerBI_Backups/@{replace(variables('WorkspaceName'),':','')}/","name":"@{items('Apply_to_each_Report')?['name']}.pbix"},"authentication":"@parameters('$authentication')"},"runtimeConfiguration":{"contentTransfer":{"transferMode":"Chunked"}}}},"runAfter":{"Parse_Report_JSON":["Succeeded"]},"type":"Foreach"},"Set_Workspace_Name_variable":{"runAfter":{},"type":"SetVariable","inputs":{"name":"WorkspaceName","value":"@items('Apply_to_each_Workspace')?['name']"}}},"runAfter":{"Parse_Workspace_JSON":["Succeeded"]},"type":"Foreach"},"Initialize_Workspace_Name_variable":{"runAfter":{},"type":"InitializeVariable","inputs":{"variables":[{"name":"WorkspaceName","type":"String"}]}}},"outputs":{}},"parameters":{"$connections":{"value":{"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]","connectionName":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]"},"onedriveforbusiness":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'onedriveforbusiness')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('onedriveforbusiness_Connection_Name'))]","connectionName":"[parameters('onedriveforbusiness_Connection_Name')]"}}}},"runtimeConfiguration":{"lifetime":{"unit":"Day","count":30},"collections":{"maximumItemCount":100000},"performanceProfile":{"throttles":{"mode":"Medium"}}}},"dependsOn":["[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]","[resourceId('Microsoft.Web/connections', parameters('onedriveforbusiness_Connection_Name'))]"]},{"type":"Microsoft.Web/connections","name":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]"},"displayName":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]"}},{"type":"Microsoft.Web/connections","name":"[parameters('onedriveforbusiness_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'onedriveforbusiness')]"},"displayName":"[parameters('onedriveforbusiness_Connection_Name')]"}}]} \ No newline at end of file diff --git a/Sessions/Craig Porteous - Power BI under Source Control/Demos/Demo3-BackupAllReports.ps1 b/Sessions/Craig Porteous - Power BI under Source Control/Demos/Demo3-BackupAllReports.ps1 index a98eee3..1dcdc27 100644 --- a/Sessions/Craig Porteous - Power BI under Source Control/Demos/Demo3-BackupAllReports.ps1 +++ b/Sessions/Craig Porteous - Power BI under Source Control/Demos/Demo3-BackupAllReports.ps1 @@ -40,8 +40,8 @@ break $workspacename = $workspace.name #Create path for workspace if it doesnt exist - if(!(Test-Path -path "C:\Users\Craig.Porteous\OneDrive - Incremental Group Ltd\PowerBI_Backups\$($workspacename)")){ - New-Item -ItemType Directory -Path "C:\Users\Craig.Porteous\OneDrive - Incremental Group Ltd\PowerBI_Backups\$($workspacename)" + if(!(Test-Path -path "C:\PowerBI_Backups\$($workspacename)")){ + New-Item -ItemType Directory -Path "C:\PowerBI_Backups\$($workspacename)" } $reporturi = "https://api.powerbi.com/v1.0/myorg/groups/$($workspaceid)/reports" @@ -54,9 +54,8 @@ break $exporturi = "https://api.powerbi.com/v1.0/myorg/groups/$($workspaceid)/reports/$($reportid)/Export" - Invoke-RestMethod -Uri $exporturi -Headers $authHeader -Method GET | Out-File -Force -FilePath "C:\Users\Craig.Porteous\OneDrive - Incremental Group Ltd\PowerBI_Backups\$($workspacename)\$($reportname).pbix" + Invoke-RestMethod -Uri $exporturi -Headers $authHeader -Method GET | Out-File -Force -FilePath "C:\PowerBI_Backups\$($workspacename)\$($reportname).pbix" } } - - # Start-Process "C:\PowerBI_Backups" \ No newline at end of file + Start-Process "C:\PowerBI_Backups" \ No newline at end of file diff --git a/Sessions/Craig Porteous - Power BI under Source Control/Flow Definition.json b/Sessions/Craig Porteous - Power BI under Source Control/Flow Definition.json new file mode 100644 index 0000000..3cae071 --- /dev/null +++ b/Sessions/Craig Porteous - Power BI under Source Control/Flow Definition.json @@ -0,0 +1,394 @@ +{ + "$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." + } + }, + "power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name": { + "defaultValue": "power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1", + "type": "String", + "metadata": { + "description": "Name of the connection." + } + }, + "onedriveforbusiness_Connection_Name": { + "defaultValue": "onedriveforbusiness", + "type": "String", + "metadata": { + "description": "Name of the connection." + } + } + }, + "resources": [ + { + "type": "Microsoft.Logic/workflows", + "name": "[parameters('logicAppName')]", + "apiVersion": "2016-06-01", + "location": "[parameters('logicAppLocation')]", + "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": { + "Recurrence": { + "recurrence": { + "frequency": "Day", + "interval": 1 + }, + "type": "Recurrence" + } + }, + "actions": { + "Get_All_Workspaces": { + "runAfter": { + "Initialize_Workspace_Name_variable": [ + "Succeeded" + ] + }, + "metadata": { + "flowSystemMetadata": { + "swaggerOperationId": "GetAllWorkspaces" + } + }, + "type": "ApiConnection", + "inputs": { + "host": { + "connection": { + "name": "@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']" + } + }, + "method": "get", + "path": "/v1.0/myorg/groups", + "authentication": "@parameters('$authentication')" + } + }, + "Parse_Workspace_JSON": { + "runAfter": { + "Get_All_Workspaces": [ + "Succeeded" + ] + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Get_All_Workspaces')", + "schema": { + "type": "object", + "properties": { + "@@odata.context": { + "type": "string" + }, + "@@odata.count": { + "type": "integer" + }, + "value": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "isReadOnly": { + "type": "boolean" + }, + "isOnDedicatedCapacity": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "required": [ + "id", + "isReadOnly", + "isOnDedicatedCapacity", + "name" + ] + } + } + } + } + } + }, + "Apply_to_each_Workspace": { + "foreach": "@body('Parse_Workspace_JSON')?['value']", + "actions": { + "Get_all_Reports": { + "runAfter": { + "Set_Workspace_Name_variable": [ + "Succeeded" + ] + }, + "metadata": { + "flowSystemMetadata": { + "swaggerOperationId": "GetAllReports" + } + }, + "type": "ApiConnection", + "inputs": { + "host": { + "connection": { + "name": "@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']" + } + }, + "method": "get", + "path": "/v1.0/myorg/groups/@{encodeURIComponent(items('Apply_to_each_Workspace')?['id'])}/reports", + "authentication": "@parameters('$authentication')" + } + }, + "Parse_Report_JSON": { + "runAfter": { + "Get_all_Reports": [ + "Succeeded" + ] + }, + "type": "ParseJson", + "inputs": { + "content": "@body('Get_all_Reports')", + "schema": { + "type": "object", + "properties": { + "@@odata.context": { + "type": "string" + }, + "value": { + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "name": { + "type": "string" + }, + "webUrl": { + "type": "string" + }, + "embedUrl": { + "type": "string" + }, + "isOwnedByMe": { + "type": "boolean" + }, + "datasetId": { + "type": "string" + } + }, + "required": [ + "id", + "name", + "webUrl", + "embedUrl", + "isOwnedByMe", + "datasetId" + ] + } + } + } + } + } + }, + "Apply_to_each_Report": { + "foreach": "@body('Parse_Report_JSON')?['value']", + "actions": { + "Export_Report": { + "runAfter": {}, + "metadata": { + "flowSystemMetadata": { + "swaggerOperationId": "ExportReport" + } + }, + "type": "ApiConnection", + "inputs": { + "host": { + "connection": { + "name": "@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']" + } + }, + "method": "get", + "path": "/v1.0/myorg/groups/@{encodeURIComponent(items('Apply_to_each_Workspace')?['id'])}/reports/@{encodeURIComponent(items('Apply_to_each_Report')?['id'])}/Export", + "authentication": "@parameters('$authentication')" + } + }, + "Create_Power_BI_file_in_OneDrive": { + "runAfter": { + "Export_Report": [ + "Succeeded" + ] + }, + "metadata": { + "flowSystemMetadata": { + "swaggerOperationId": "CreateFile" + } + }, + "type": "ApiConnection", + "inputs": { + "host": { + "connection": { + "name": "@parameters('$connections')['onedriveforbusiness']['connectionId']" + } + }, + "method": "post", + "body": "@body('Export_Report')", + "path": "/datasets/default/files", + "queries": { + "folderPath": "PowerBI_Backups/@{items('Apply_to_each_Workspace')?['name']}/", + "name": "@{items('Apply_to_each_Report')?['name']}.pbix" + }, + "authentication": "@parameters('$authentication')" + }, + "runtimeConfiguration": { + "contentTransfer": { + "transferMode": "Chunked" + } + } + } + }, + "runAfter": { + "Parse_Report_JSON": [ + "Succeeded" + ] + }, + "type": "Foreach" + }, + "Set_Workspace_Name_variable": { + "runAfter": {}, + "type": "SetVariable", + "inputs": { + "name": "WorkspaceName", + "value": "@items('Apply_to_each_Workspace')?['name']" + } + } + }, + "runAfter": { + "Parse_Workspace_JSON": [ + "Succeeded" + ] + }, + "type": "Foreach" + }, + "Initialize_Workspace_Name_variable": { + "runAfter": {}, + "type": "InitializeVariable", + "inputs": { + "variables": [ + { + "name": "WorkspaceName", + "type": "String" + } + ] + } + } + }, + "outputs": {} + }, + "parameters": { + "$connections": { + "value": { + "power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1": { + "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]", + "connectionId": "[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]", + "connectionName": "[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]" + }, + "onedriveforbusiness": { + "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'onedriveforbusiness')]", + "connectionId": "[resourceId('Microsoft.Web/connections', parameters('onedriveforbusiness_Connection_Name'))]", + "connectionName": "[parameters('onedriveforbusiness_Connection_Name')]" + } + } + } + }, + "runtimeConfiguration": { + "lifetime": { + "unit": "Day", + "count": 30 + }, + "collections": { + "maximumItemCount": 100000 + }, + "performanceProfile": { + "throttles": { + "mode": "Medium" + } + } + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]", + "[resourceId('Microsoft.Web/connections', parameters('onedriveforbusiness_Connection_Name'))]" + ] + }, + { + "type": "Microsoft.Web/connections", + "name": "[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]", + "apiVersion": "2016-06-01", + "location": "[parameters('logicAppLocation')]", + "properties": { + "api": { + "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]" + }, + "displayName": "[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]" + } + }, + { + "type": "Microsoft.Web/connections", + "name": "[parameters('onedriveforbusiness_Connection_Name')]", + "apiVersion": "2016-06-01", + "location": "[parameters('logicAppLocation')]", + "properties": { + "api": { + "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'onedriveforbusiness')]" + }, + "displayName": "[parameters('onedriveforbusiness_Connection_Name')]" + } + } + ] +} \ No newline at end of file diff --git a/Sessions/Craig Porteous - Power BI under Source Control/Power BI Governance Webhook Flow Definition.json b/Sessions/Craig Porteous - Power BI under Source Control/Power BI Governance Webhook Flow Definition.json index e32774c..cf21c5f 100644 --- a/Sessions/Craig Porteous - Power BI under Source Control/Power BI Governance Webhook Flow Definition.json +++ b/Sessions/Craig Porteous - Power BI under Source Control/Power BI Governance Webhook Flow Definition.json @@ -1 +1 @@ -{"template":{"$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."}},"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name":{"defaultValue":"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1","type":"String","metadata":{"description":"Name of the connection."}},"twitter_Connection_Name":{"defaultValue":"twitter","type":"String","metadata":{"description":"Name of the connection."}},"sharepointonline_Connection_Name":{"defaultValue":"sharepointonline","type":"String","metadata":{"description":"Name of the connection."}}},"resources":[{"type":"Microsoft.Logic/workflows","name":"[parameters('logicAppName')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","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":"array","items":{"type":"object","properties":{"clientId":{"type":"string"},"contentCreated":{"type":"string"},"contentExpiration":{"type":"string"},"contentId":{"type":"string"},"contentType":{"type":"string"},"contentUri":{"type":"string"},"tenantId":{"type":"string"}},"required":["clientId","contentCreated","contentExpiration","contentId","contentType","contentUri","tenantId"]}}}}},"actions":{"HTTP_-_Get_Token":{"runAfter":{"Set_Variables":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"https://login.microsoftonline.com/@{outputs('Tenant_Id')}/oauth2/token","headers":{"Content-Type":"application/x-www-form-urlencoded"},"body":"client_id=@{outputs('Client_Id')}&client_Secret=@{outputs('Client_Key')}&resource=https://manage.office.com&grant_type=client_credentials"}},"Parse_Token_Response":{"runAfter":{"HTTP_-_Get_Token":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('HTTP_-_Get_Token')","schema":{"type":"object","properties":{"token_type":{"type":"string"},"expires_in":{"type":"string"},"ext_expires_in":{"type":"string"},"expires_on":{"type":"string"},"not_before":{"type":"string"},"resource":{"type":"string"},"access_token":{"type":"string"}}}}},"HTTP_-_Get_Log_Event":{"runAfter":{"Parse_Token_Response":["Succeeded"]},"type":"Http","inputs":{"method":"GET","uri":"@{triggerBody()[0]?['contentUri']}","headers":{"Authorization":"Bearer @{body('Parse_Token_Response')?['access_token']}"}}},"Parse_Log_Event":{"runAfter":{"HTTP_-_Get_Log_Event":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('HTTP_-_Get_Log_Event')","schema":{"type":"array","items":{"type":"object","properties":{"CreationTime":{"type":"string"},"Id":{"type":"string"},"Operation":{"type":"string"},"OrganizationId":{"type":"string"},"RecordType":{"type":"integer"},"ResultStatus":{"type":"string"},"UserKey":{"type":"string"},"UserType":{"type":"integer"},"Version":{"type":"integer"},"Workload":{"type":"string"},"ObjectId":{"type":"string"},"UserId":{"type":"string"},"DatasetId":{"type":"string"},"DatasetName":{"type":"string"},"ReportId":{"type":"string"},"ReportName":{"type":"string"},"WorkspaceName":{"type":"string"},"WorkspaceId":{"type":"string"}}}}}},"Apply_to_each":{"foreach":"@body('Parse_Log_Event')","actions":{"Condition_-_if_CreateReport_Event":{"actions":{"Export_Report":{"runAfter":{},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"ExportReport"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']"}},"method":"get","path":"/v1.0/myorg/groups/@{encodeURIComponent(items('Apply_to_each')?['WorkspaceId'])}/reports/@{encodeURIComponent(items('Apply_to_each')?['ReportId'])}/Export","authentication":"@parameters('$authentication')"}},"Post_a_tweet":{"runAfter":{"Create_file_2":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"Tweet"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['twitter']['connectionId']"}},"method":"post","path":"/posttweet","queries":{"tweetText":" @{items('Apply_to_each')?['UserId']} Deployed @{items('Apply_to_each')?['ReportName']}to @{items('Apply_to_each')?['WorkspaceName']}. Backup complete to @{body('Create_file_2')?['Path']}#PowerBIUnderSourceControl #Automation #Governance #PowerBI"},"authentication":"@parameters('$authentication')"}},"Create_file_2":{"runAfter":{"Export_Report":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"CreateFile"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['sharepointonline']['connectionId']"}},"method":"post","body":"@body('Export_Report')","path":"/datasets/@{encodeURIComponent(encodeURIComponent('https://craigporteous.sharepoint.com/sites/demos'))}/files","queries":{"folderPath":"/Shared Documents/Forms/Document/@{items('Apply_to_each')?['WorkspaceName']}/","name":"@{items('Apply_to_each')?['ReportName']}.pbix","queryParametersSingleEncoded":true},"authentication":"@parameters('$authentication')"}}},"runAfter":{},"expression":{"or":[{"equals":["@items('Apply_to_each')['Operation']","CreateReport"]},{"and":[{"equals":["@items('Apply_to_each')?['Operation']","Import"]},{"equals":["@items('Apply_to_each')?['Workload']","PowerBI"]}]}]},"type":"If"}},"runAfter":{"Parse_Log_Event":["Succeeded"]},"type":"Foreach"},"Set_Variables":{"actions":{"Client_Key":{"runAfter":{},"trackedProperties":{"client_id":"8b9aca1a-575e-427d-8caa-736963851e19","client_key":":Jxrye:qcH+FRVD@2y8DkzkD30cOFV39","tenant":"d6820790-2f79-4257-9645-887464e776fa"},"type":"Compose","inputs":"%40bnHL2%2AdsQbl6T0n%2B%2FYcjDB5b%3AVAm.%2B%2F"},"Client_Id":{"runAfter":{"Client_Key":["Succeeded"]},"type":"Compose","inputs":"bef05ee1-aa25-4474-89cc-3bd7af3b9aea"},"Tenant_Id":{"runAfter":{"Client_Id":["Succeeded"]},"type":"Compose","inputs":"32b3d78d-65c2-436b-b5af-69c7d983ac4b"}},"runAfter":{},"type":"Scope"}}},"parameters":{"$connections":{"value":{"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]","connectionName":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]"},"twitter":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'twitter')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('twitter_Connection_Name'))]","connectionName":"[parameters('twitter_Connection_Name')]"},"sharepointonline":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'sharepointonline')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('sharepointonline_Connection_Name'))]","connectionName":"[parameters('sharepointonline_Connection_Name')]"}}}},"runtimeConfiguration":{"lifetime":{"unit":"Day","count":30},"collections":{"maximumItemCount":100000},"performanceProfile":{"throttles":{"mode":"Medium"}}}},"dependsOn":["[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]","[resourceId('Microsoft.Web/connections', parameters('twitter_Connection_Name'))]","[resourceId('Microsoft.Web/connections', parameters('sharepointonline_Connection_Name'))]"]},{"type":"Microsoft.Web/connections","name":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]"},"displayName":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]"}},{"type":"Microsoft.Web/connections","name":"[parameters('twitter_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'twitter')]"},"displayName":"[parameters('twitter_Connection_Name')]"}},{"type":"Microsoft.Web/connections","name":"[parameters('sharepointonline_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'sharepointonline')]"},"displayName":"[parameters('sharepointonline_Connection_Name')]"}}]}} \ No newline at end of file +{"$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."}},"twitter_Connection_Name":{"defaultValue":"twitter","type":"String","metadata":{"description":"Name of the connection."}},"sharepointonline_Connection_Name":{"defaultValue":"sharepointonline","type":"String","metadata":{"description":"Name of the connection."}},"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name":{"defaultValue":"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1","type":"String","metadata":{"description":"Name of the connection."}}},"resources":[{"type":"Microsoft.Logic/workflows","name":"[parameters('logicAppName')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","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":"array","items":{"type":"object","properties":{"clientId":{"type":"string"},"contentCreated":{"type":"string"},"contentExpiration":{"type":"string"},"contentId":{"type":"string"},"contentType":{"type":"string"},"contentUri":{"type":"string"},"tenantId":{"type":"string"}},"required":["clientId","contentCreated","contentExpiration","contentId","contentType","contentUri","tenantId"]}}}}},"actions":{"HTTP_-_Get_Token":{"runAfter":{"Set_Variables":["Succeeded"]},"type":"Http","inputs":{"method":"POST","uri":"https://login.microsoftonline.com/@{outputs('Tenant_Id')}/oauth2/token","headers":{"Content-Type":"application/x-www-form-urlencoded"},"body":"client_id=@{outputs('Client_Id')}&client_Secret=@{outputs('Client_Key')}&resource=https://manage.office.com&grant_type=client_credentials"}},"Parse_Token_Response":{"runAfter":{"HTTP_-_Get_Token":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('HTTP_-_Get_Token')","schema":{"type":"object","properties":{"token_type":{"type":"string"},"expires_in":{"type":"string"},"ext_expires_in":{"type":"string"},"expires_on":{"type":"string"},"not_before":{"type":"string"},"resource":{"type":"string"},"access_token":{"type":"string"}}}}},"HTTP_-_Get_Log_Event":{"runAfter":{"Parse_Token_Response":["Succeeded"]},"type":"Http","inputs":{"method":"GET","uri":"@{triggerBody()[0]?['contentUri']}","headers":{"Authorization":"Bearer @{body('Parse_Token_Response')?['access_token']}"}}},"Parse_O365_Log_Event":{"runAfter":{"HTTP_-_Get_Log_Event":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('HTTP_-_Get_Log_Event')","schema":{"type":"array","items":{"type":"object","properties":{"CreationTime":{"type":"string"},"Id":{"type":"string"},"Operation":{"type":"string"},"OrganizationId":{"type":"string"},"RecordType":{"type":"integer"},"ResultStatus":{"type":"string"},"UserKey":{"type":"string"},"UserType":{"type":"integer"},"Version":{"type":"integer"},"Workload":{"type":"string"},"ObjectId":{"type":"string"},"UserId":{"type":"string"},"DatasetId":{"type":"string"},"DatasetName":{"type":"string"},"ReportId":{"type":"string"},"ReportName":{"type":"string"},"WorkspaceName":{"type":"string"},"WorkspaceId":{"type":"string"},"ImportId":{"type":"string"}}}}}},"Apply_to_each_O365_Log_event":{"foreach":"@body('Parse_O365_Log_Event')","actions":{"Condition_-_if_Import_[Operation]_in_PowerBI_[Workload]":{"actions":{"Get_Report_info_from_Import_details":{"runAfter":{},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"GetImport"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']"}},"method":"get","path":"/v1.0/myorg/groups/@{encodeURIComponent(items('Apply_to_each_O365_Log_event')?['WorkspaceId'])}/imports/@{encodeURIComponent(items('Apply_to_each_O365_Log_event')?['ImportId'])}","authentication":"@parameters('$authentication')"}},"Parse_Import_JSON":{"runAfter":{"Get_Report_info_from_Import_details":["Succeeded"]},"type":"ParseJson","inputs":{"content":"@body('Get_Report_info_from_Import_details')","schema":{"type":"object","properties":{"id":{"type":"string"},"importState":{"type":"string"},"createdDateTime":{"type":"string"},"updatedDateTime":{"type":"string"},"name":{"type":"string"},"connectionType":{"type":"string"},"source":{"type":"string"},"datasets":{"type":"array","items":{"type":"object","properties":{"datasetid":{"type":"string"},"name":{"type":"string"},"webUrl":{"type":"string"}},"required":["id","name","webUrl"]}},"reports":{"type":"array","items":{"type":"object","properties":{"reportid":{"type":"string"},"reportname":{"type":"string"},"webUrl":{"type":"string"},"embedUrl":{"type":"string"}},"required":["id","name","webUrl","embedUrl"]}}}}}},"Apply_to_each_Report_in_the_Import":{"foreach":"@body('Parse_Import_JSON')?['reports']","actions":{"Export_Report":{"runAfter":{},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"ExportReport"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1']['connectionId']"}},"method":"get","path":"/v1.0/myorg/groups/@{encodeURIComponent(items('Apply_to_each_O365_Log_event')?['WorkspaceId'])}/reports/@{encodeURIComponent(items('Apply_to_each_Report_in_the_Import')?['reportid'])}/Export","authentication":"@parameters('$authentication')"}},"Create_file_2":{"runAfter":{"Export_Report":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"CreateFile"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['sharepointonline']['connectionId']"}},"method":"post","body":"@body('Export_Report')","path":"/datasets/@{encodeURIComponent(encodeURIComponent('https://craigporteous.sharepoint.com/sites/demos'))}/files","queries":{"folderPath":"/Shared Documents/@{items('Apply_to_each_O365_Log_event')?['WorkspaceName']}/","name":"@{items('Apply_to_each_Report_in_the_Import')?['reportname']}.pbix","queryParametersSingleEncoded":true},"authentication":"@parameters('$authentication')"}},"Post_a_tweet":{"runAfter":{"Create_file_2":["Succeeded"]},"metadata":{"flowSystemMetadata":{"swaggerOperationId":"Tweet"}},"type":"ApiConnection","inputs":{"host":{"connection":{"name":"@parameters('$connections')['twitter']['connectionId']"}},"method":"post","path":"/posttweet","queries":{"tweetText":"I ❤ #MicrosoftFlow - Craig deployed \"@{body('Create_file_2')?['DisplayName']}\" to the \"@{items('Apply_to_each_O365_Log_event')?['WorkspaceName']}\" workspace. Backup complete to @{body('Create_file_2')?['Path']}. #PowerBIUnderSourceControl #Automation #Governance #PowerBI #MVPBuzz"},"authentication":"@parameters('$authentication')"}}},"runAfter":{"Parse_Import_JSON":["Succeeded"]},"type":"Foreach"}},"runAfter":{},"expression":{"and":[{"equals":["","PowerBI"]},{"equals":["","Import"]}]},"type":"If"}},"runAfter":{"Parse_O365_Log_Event":["Succeeded"]},"type":"Foreach"},"Set_Variables":{"actions":{"Client_Key":{"runAfter":{},"trackedProperties":{"client_id":"8b9aca1a-575e-427d-8caa-736963851e19","client_key":":Jxrye:qcH+FRVD@2y8DkzkD30cOFV39","tenant":"d6820790-2f79-4257-9645-887464e776fa"},"type":"Compose","inputs":"%40bnHL2%2AdsQbl6T0n%2B%2FYcjDB5b%3AVAm.%2B%2F"},"Client_Id":{"runAfter":{"Client_Key":["Succeeded"]},"type":"Compose","inputs":"bef05ee1-aa25-4474-89cc-3bd7af3b9aea"},"Tenant_Id":{"runAfter":{"Client_Id":["Succeeded"]},"type":"Compose","inputs":"32b3d78d-65c2-436b-b5af-69c7d983ac4b"}},"runAfter":{},"type":"Scope"}}},"parameters":{"$connections":{"value":{"twitter":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'twitter')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('twitter_Connection_Name'))]","connectionName":"[parameters('twitter_Connection_Name')]"},"sharepointonline":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'sharepointonline')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('sharepointonline_Connection_Name'))]","connectionName":"[parameters('sharepointonline_Connection_Name')]"},"power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]","connectionId":"[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]","connectionName":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]"}}}},"runtimeConfiguration":{"lifetime":{"unit":"Day","count":30},"collections":{"maximumItemCount":100000},"performanceProfile":{"throttles":{"mode":"Medium"}}}},"dependsOn":["[resourceId('Microsoft.Web/connections', parameters('twitter_Connection_Name'))]","[resourceId('Microsoft.Web/connections', parameters('sharepointonline_Connection_Name'))]","[resourceId('Microsoft.Web/connections', parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name'))]"]},{"type":"Microsoft.Web/connections","name":"[parameters('twitter_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'twitter')]"},"displayName":"[parameters('twitter_Connection_Name')]"}},{"type":"Microsoft.Web/connections","name":"[parameters('sharepointonline_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'sharepointonline')]"},"displayName":"[parameters('sharepointonline_Connection_Name')]"}},{"type":"Microsoft.Web/connections","name":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]","apiVersion":"2016-06-01","location":"[parameters('logicAppLocation')]","properties":{"api":{"id":"[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/', parameters('logicAppLocation'), '/managedApis/', 'power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1')]"},"displayName":"[parameters('power.20bi.20source.20control.5fea6c3a7adc4ca84-8f1ba12ad457bce1_Connection_Name')]"}}]} \ No newline at end of file