{"id":974,"date":"2019-05-03T09:00:00","date_gmt":"2019-05-03T16:00:00","guid":{"rendered":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/custom-connector-microsoft-flow-search-unified-audit-log\/"},"modified":"2019-05-03T09:00:00","modified_gmt":"2019-05-03T16:00:00","slug":"custom-connector-microsoft-flow-search-unified-audit-log","status":"publish","type":"power-automate","link":"https:\/\/www.microsoft.com\/en-us\/power-platform\/blog\/power-automate\/custom-connector-microsoft-flow-search-unified-audit-log\/","title":{"rendered":"Advanced | Flow of the Week: Build a Custom Connector for Microsoft Flow & Search Unified Audit Logs"},"content":{"rendered":"

In this post, Joao Lucindo, a Microsoft TSP hailing from Brazil shows you how to develop a Microsoft Flow Custom\u00a0 Connector to get audit logs from Office 365. This solution is based on the Search-UnifiedAuditLog cmdlet<\/a>.<\/p>\n

Step-by-Step<\/h1>\n

1) Access Microsoft Flow<\/a>, log in and select the gear icon in the top right-hand corner and then click “Custom Connectors”.<\/p>\n

\"\"
\n2) Click “+Create custom Connector” and choose “Create from blank”<\/p>\n

\"\"
\n3) Choose a name for your custom connector<\/p>\n

\"\"<\/p>\n

4)Fill the fields like the print screen below, and then click “Security”:<\/p>\n

\"\"<\/p>\n

Icon background color: choose a color in hex format<\/strong><\/p>\n

Description: g<\/strong>ive a description for your custom connector<\/strong><\/p>\n

Host: outlook.office365.co<\/strong><\/p>\n

5) Choose “Basic authentication” for the Authentication Type, and fill the Parameter label field with “UserName” and “Password” like the print screen below (Do NOT enter secrets here. These fields are used to configure display names for connections). Finally click “Definition”<\/p>\n

\"\"<\/p>\n

6) In the “Definition” step, click “New Action”<\/p>\n

\"\"<\/p>\n

7) Fill all the field with “GetLogs”, like the image below, and then select “+ Import From sample”<\/p>\n

\"\"<\/p>\n

8) Choose the verb “Get”. In the field URL paste: <https:\/\/outlook.office365.com\/psws\/service.svc\/UnifiedAuditLog?StartDate={STARTDATE}&EndDate={ENDDATE}&RecordType={RECORDTYPE}&ResultSize={RESULTSIZE}<\/a>>. Finally click “Import”<\/p>\n

\"\"<\/p>\n

\u00a0<\/p>\n

9) In the query parameter “RecordType” click “Edit”<\/p>\n

\"\"<\/p>\n

10) Change the “Is required” option to “Yes”; The “Dropdown type” to “Static”; and then paste <AzureActiveDirectory, AzureActiveDirectoryAccountLogon, AzureActiveDirectoryStsLogon, ComplianceDLPExchange, ComplianceDLPSharePoint, Discovery, ExchangeAdmin, ExchangeAggregatedOperation, ExchangeItem, ExchangeItemGroup, MicrosoftTeams, MicrosoftTeamsAddOns, MicrosoftTeamsSettingsOperation, OneDrive, PowerBIAudit, SecurityComplianceAlerts, SecurityComplianceCenterEOPCmdlet, SecurityComplianceInsights, SharePoint, SharePointFileOperation, SharePointSharingOperation, SkypeForBusinessCmdlets, SkypeForBusinessPSTNUsage, SkypeForBusinessUsersBlocked, Sway, ThreatIntelligence, Yammer, MicrosoftStream<\/strong>> in the field “Values”<\/p>\n

\"\"<\/p>\n

11) Repeat the same for the others Query parameters (StartDate,EndDate,ResultSize), but this time only change the “Is required” field to “Yes”<\/p>\n

\"\"<\/p>\n

12) Select “Create connector”, wait for a few seconds to conclude the creation connector process, and then click “Test”<\/p>\n

\"\"<\/p>\n

13) Select “New connection”<\/p>\n

\"\"<\/p>\n

14) Type the email and password for the Global admin account, and then select “Create connection”<\/p>\n

\"\"<\/p>\n

15) If necessary, click in the refresh icon to activate the new connection that we just created. Fill the fields “StartDate<\/strong>” and “EndDate<\/strong>” (YYYY-MM-DD)*. For the “RecordType<\/strong>” field choose one of the options from the step 10. For the “ResultSize” field fill with 5000. Finally click “Test operation”<\/p>\n

*Audit record is generated and stored in the Office 365 audit log for your organization. The length of time that an audit record is retained (and searchable in the audit log) depends on your Office 365 subscription, and specifically the type of the license that is assigned to a specific user.<\/p>\n