Set Up Your Azure Cognitive Services
- Create an Azure account if you don't have one. Visit the Azure Portal to start the process.
- In the Azure Portal, search for "Cognitive Services" and click on it.
- Click "Create" and select the specific cognitive service you wish to integrate, such as "Computer Vision" or "Text Analytics".
- Fill in the required details like the subscription, resource group, and pricing tier. Once configured, click on "Review + Create" and then "Create" to instantiate the service.
- Navigate to the newly created service and get the necessary keys and endpoint URL, which will be needed for integration with SharePoint.
Prepare Microsoft SharePoint
- Ensure you have administrative access to the SharePoint site where the integration will occur.
- Familiarize yourself with Microsoft Graph API, as it is often used to interact with SharePoint data.
Azure Function as a Middleman
- Log into the Azure Portal, and navigate to "Azure Functions".
- Create a new Function App by clicking "Add". Fill in necessary details like the function app name and hosting details.
- Once created, go to the new Function App and create a new function. Select an HTTP trigger for simplicity.
- In the function's code editor, write the necessary code to call the Azure Cognitive Service. For instance, a Python example for Computer Vision service:
import requests
import json
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
key = "YOUR_COGNITIVE_SERVICE_KEY"
endpoint = "YOUR_COGNITIVE_SERVICE_ENDPOINT"
headers = {"Ocp-Apim-Subscription-Key": key, "Content-Type": "application/json"}
params = {"visualFeatures": "Categories,Description,Color"}
image_url = req.params.get("image_url")
if not image_url:
return func.HttpResponse("Image URL is required.", status_code=400)
response = requests.post(endpoint + "/vision/v3.1/analyze", headers=headers, params=params, json={"url": image_url})
if response.status_code == 200:
return func.HttpResponse(response.text, status_code=200)
else:
return func.HttpResponse(response.text, status_code=response.status_code)
Integrate with Microsoft SharePoint
- Use Microsoft Power Automate to call the Azure Function whenever an item is added or updated in SharePoint.
- Create a new flow in Power Automate. Start with the "When an item is created or modified" trigger for SharePoint.
- Add an action to "HTTP" to call the Azure Function. Pass necessary parameters like the document URL or any required details.
Test and Validate
- Test the integration by adding or modifying an item in the configured SharePoint site. Monitor the flow to ensure it triggers the Azure Function successfully.
- Check the Azure Function logs to verify it is receiving the data correctly and returning the processed information as expected.
- Review the output within SharePoint to ensure that the desired cognitive service processes have been applied correctly.