1+ {
2+ "cells" : [
3+ {
4+ "cell_type" : " markdown" ,
5+ "id" : " 2722b419" ,
6+ "metadata" : {},
7+ "source" : [
8+ " [](https://colab.research.google.com/github/openlayer-ai/openlayer-python/blob/main/examples/tracing/azure-content-understanding/azure_content_understanding_tracing.ipynb)\n " ,
9+ " \n " ,
10+ " \n " ,
11+ " # <a id=\" top\" >Azure Content Understanding tracing quickstart</a>\n " ,
12+ " \n " ,
13+ " This notebook illustrates how to get started monitoring Azure Content Understanding with Openlayer."
14+ ]
15+ },
16+ {
17+ "cell_type" : " code" ,
18+ "execution_count" : null ,
19+ "id" : " 020c8f6a" ,
20+ "metadata" : {},
21+ "outputs" : [],
22+ "source" : [
23+ " !pip install openlayer azure-ai-contentunderstanding azure-identity"
24+ ]
25+ },
26+ {
27+ "cell_type" : " markdown" ,
28+ "id" : " 75c2a473" ,
29+ "metadata" : {},
30+ "source" : [
31+ " ## 1. Set the environment variables"
32+ ]
33+ },
34+ {
35+ "cell_type" : " code" ,
36+ "execution_count" : null ,
37+ "id" : " f3f4fa13" ,
38+ "metadata" : {},
39+ "outputs" : [],
40+ "source" : [
41+ " import os\n " ,
42+ " \n " ,
43+ " # Azure Content Understanding env variables\n " ,
44+ " os.environ[\" AZURE_CONTENT_UNDERSTANDING_ENDPOINT\" ] = \" YOUR_AZURE_CONTENT_UNDERSTANDING_ENDPOINT_HERE\"\n " ,
45+ " os.environ[\" AZURE_CONTENT_UNDERSTANDING_KEY\" ] = \" YOUR_AZURE_CONTENT_UNDERSTANDING_KEY_HERE\"\n " ,
46+ " \n " ,
47+ " # Openlayer env variables\n " ,
48+ " os.environ[\" OPENLAYER_API_KEY\" ] = \" YOUR_OPENLAYER_API_KEY_HERE\"\n " ,
49+ " os.environ[\" OPENLAYER_INFERENCE_PIPELINE_ID\" ] = \" YOUR_OPENLAYER_INFERENCE_PIPELINE_ID_HERE\" "
50+ ]
51+ },
52+ {
53+ "cell_type" : " markdown" ,
54+ "id" : " 9758533f" ,
55+ "metadata" : {},
56+ "source" : [
57+ " ## 2. Import the `trace_azure_content_understanding` function and create the client"
58+ ]
59+ },
60+ {
61+ "cell_type" : " code" ,
62+ "execution_count" : null ,
63+ "id" : " e60584fa" ,
64+ "metadata" : {},
65+ "outputs" : [],
66+ "source" : [
67+ " from azure.core.credentials import AzureKeyCredential\n " ,
68+ " from azure.ai.contentunderstanding import ContentUnderstandingClient\n " ,
69+ " from azure.ai.contentunderstanding.models import AnalysisInput\n " ,
70+ " \n " ,
71+ " from openlayer.lib import configure, trace_azure_content_understanding\n " ,
72+ " \n " ,
73+ " # Configure if you want to upload documents to Openlayer storage\n " ,
74+ " configure(\n " ,
75+ " attachment_upload_enabled=True, # upload binary/file attachments\n " ,
76+ " url_upload_enabled=True, # also download & re-upload external URLs\n " ,
77+ " )\n " ,
78+ " \n " ,
79+ " client = trace_azure_content_understanding(\n " ,
80+ " ContentUnderstandingClient(\n " ,
81+ " endpoint=os.environ.get(\" AZURE_CONTENT_UNDERSTANDING_ENDPOINT\" ),\n " ,
82+ " credential=AzureKeyCredential(os.environ.get(\" AZURE_CONTENT_UNDERSTANDING_KEY\" )),\n " ,
83+ " api_version=\" 2025-11-01\" ,\n " ,
84+ " )\n " ,
85+ " )"
86+ ]
87+ },
88+ {
89+ "cell_type" : " markdown" ,
90+ "id" : " 72a6b954" ,
91+ "metadata" : {},
92+ "source" : [
93+ " ## 3. Use your traced client normally"
94+ ]
95+ },
96+ {
97+ "cell_type" : " markdown" ,
98+ "id" : " 76a350b4" ,
99+ "metadata" : {},
100+ "source" : [
101+ " That's it! Now you can continue using your Azure Content Understanding client normally. The data is automatically published to Openlayer and you can start creating tests around it!"
102+ ]
103+ },
104+ {
105+ "cell_type" : " code" ,
106+ "execution_count" : null ,
107+ "id" : " e00c1c79" ,
108+ "metadata" : {},
109+ "outputs" : [],
110+ "source" : [
111+ " analyzer_id = \" prebuilt-read\"\n " ,
112+ " url = \" https://contentunderstanding.ai.azure.com/assets/prebuilt/read_healthcare.png\"\n " ,
113+ " \n " ,
114+ " poller = client.begin_analyze(\n " ,
115+ " analyzer_id=analyzer_id,\n " ,
116+ " inputs=[AnalysisInput(url=url)],\n " ,
117+ " )\n " ,
118+ " result = poller.result()"
119+ ]
120+ },
121+ {
122+ "cell_type" : " code" ,
123+ "execution_count" : null ,
124+ "id" : " abaf6987-c257-4f0d-96e7-3739b24c7206" ,
125+ "metadata" : {},
126+ "outputs" : [],
127+ "source" : []
128+ }
129+ ],
130+ "metadata" : {
131+ "kernelspec" : {
132+ "display_name" : " hr-benefits" ,
133+ "language" : " python" ,
134+ "name" : " python3"
135+ },
136+ "language_info" : {
137+ "codemirror_mode" : {
138+ "name" : " ipython" ,
139+ "version" : 3
140+ },
141+ "file_extension" : " .py" ,
142+ "mimetype" : " text/x-python" ,
143+ "name" : " python" ,
144+ "nbconvert_exporter" : " python" ,
145+ "pygments_lexer" : " ipython3" ,
146+ "version" : " 3.12.13"
147+ }
148+ },
149+ "nbformat" : 4 ,
150+ "nbformat_minor" : 5
151+ }
0 commit comments