SOLUTIONS FOR MICROSOFT 365

Finding Stuff — Using Azure Search and Graph Connectors to Search Your Data.

Searching stuff is time-consuming. Let’s use Azure Search and Graph Connectors to make the Power BI documentation — or any other source — searchable from within your Microsoft 365 and line of business Apps

Sebastian Zolg 🤝
Towards Data Science
6 min readJun 7, 2020

--

Photo by Edi Libedinsky on Unsplash

With the introduction of Graph Connectors for Microsoft Search, we can now query any content from within our favorite Microsoft 365 Apps like SharePoint or our line of business applications using the Graph Search API.

This article guides you through the creation of such a connector using the Microsoft Power BI public documentation as a source for our search.

Following this guide, you’ll get the below result from within your Microsoft 365 Apps.

Query any data from within Microsoft 365 Apps

Creating a Graph Connector

To create our first connector, we open the Admin Center and go to Settings > Microsoft Search. Switch to the Connectors Tab and click +Add.

From the list of built-in connectors, select Enterprise websites, and click Next.

Give your Connector a name like Power BI Fundamentals Docs and an ID like powerBiFundamentalsDocs, check the terms and services (worth reading!) and click Next.

We now enter the URL from where we crawl the data into the Graph.

For our scenario, we point the connector to the Power BI Fundamentals documentation. Feel free to crawl any other documentation or data on the web.

Note: Depending on the size of the website you’re crawling, it might take several hours to populate fully.

Select None for the Authentication type, click Test connection, and finish by clicking Next.

Feel free to filter the URLs even further or leave it blank to crawl everything below the given URL. Click Next.

Leave the schema as is and click Next.

The Enterprise Website connector doesn’t support permissions so far, so everyone in the organization can search for it. Click Next.

Set the Full refresh interval to anything you want and click Next.

Important Note: Please always respect the web scraping and crawling policy of any website you crawl.

Review everything and click Finish adding.

The connector takes a couple of minutes to be created. Use the Refresh icon above to refresh the Connection state.

When the connector is ready, click Create Result type in the Required actions column.

In the next couple of steps, we’re defining how search results are displayed and which data the result contains.

Give the result type a name like Power BI Fundamentals Docs and click Next.

Select the connector we created before and click Next.

Leave the Rules as is. This would allow us to switch between various result types based on some conditions. Click Next.

Before we click Launch Layout Designer, note the list of Available Properties below. These are the properties returned by the Enterprise Website connector.

In the Layout Designer, we choose from a list of templates to visualize the search results. We go for the first and simplest one and click Get Started.

Now we map the visual representation of the search results with the available properties of our connector. Put the Title, URL, and Description properties accordingly and click Generate and Copy JSON.

Back in the result type wizard, paste the generated JSON from your clipboard and click Next.

Review everything and click Add result type.

Once confirmed, click Done.

Now it is time to create a vertical. This is basically how our users will see the search tab inside any Microsoft 365 App like SharePoint.

Click Create Vertical.

Please give it a user-friendly name like Power BI Fundamentals and click Next.

Choose the previously created Connector and click Next.

Leave the Query empty and click Next.

Once confirmed, click Enable vertical before you click Done.

That’s it! Now it is time to search for some content from within your SharePoint.

Searching in SharePoint and other places 🔎

Searching for the content is straight forward and works in various places. Here are a few places from where you can search:

SharePoint

What is Power BI?

Note: To see these results, the user must have a proper license assigned. According to the documentation, it is either Microsoft 365 for enterprise E3/E5 or Microsoft 365 Education A3/A5. According to my tests, searching through the API works in any case (see a sample below).

Office 365 Portal

What is Power BI?

Windows 10 Office App from the Windows Store

What is Power BI?

Using the Graph Search API ⚡

Besides searching the connector from inside various Microsoft 365 Apps, we can easily embed it in our line of business apps, scripts, or the command-line.

For this, we use the Graph API, and it’s search endpoint.The easiest way to test this is by using the Graph Explorer.

Make sure you’re signed in to the Graph Explorer. Before you can query external connectors, you need consent for your app, which in this case, is the Graph Explorer (it is just an app like any other).

To do so, click the Modify permission tab and click Consent next to the External.Read.All permission scope.

Once granted, we can fire a put request to the search endpoint using the below payload.

put: https://graph.microsoft.com/beta/search/query

Please note the contentSources array, which must match your connector ID.

Adjust the query_string as you like and fire the request using the Run query button and explore the response preview.

This approach works for any custom application or script. Use the available Graph libraries for many different programming languages and platforms to integrate the search inside your applications.

That’s it! Have fun!

Make it so 👉,
Sebastian

--

--

I’m an IT professional with experience in enterprise mobility, workplace, cloud technologies, and software development. sebastianzolg.de