Costa Rica
Last updated: 2025-10-01
Note
Here are a few examples that demonstrate the deployment process and the creation of E2E solution. Please feel free to use them as references if needed.
- Demo: Azure Implementation - PDF Layout Extraction with Azure AI Document Intelligence Supporting Multiple Document Versions with Visual Selection Cues (full-code approach)
- Demo: Automated PDF Invoice Processing with Open Framework (full-code approach)
- Demo: PDF Layout Extraction with Doc Intelligence (full-code approach)
- Demo: Automated PDF Invoice Processing with Doc Intelligence (full-code approach)
In the context of Azure Function Apps, a
hosting option refers to the plan you choose to run your function app. This choice affects how your function app is scaled, the resources available to each function app instance, and the support for advanced functionalities like virtual network connectivity and container support.
Tip
Scale to Zero: Indicates whether the service can automatically scale down to zero instances when idle.- IDLE stands for:
- I – Inactive
- D – During
- L – Low
- E – Engagement
- In other words, when the application is not actively handling requests or events (it's in a low-activity or paused state).
- IDLE stands for:
Scale Behavior: Describes how the service scales (e.g.,event-driven,dedicated, orcontainerized).Virtual Networking: Whether the service supports integration with virtual networks for secure communication.Dedicated Compute & Reserved Cold Start: Availability of always-on compute to avoid cold starts and ensure low latency.Max Scale Out (Instances): Maximum number of instances the service can scale out to.Example AI Use Cases: Real-world scenarios where each plan excels.
Flex Consumption
| Feature | Description |
|---|---|
| Scale to Zero | Yes |
| Scale Behavior | Fast event-driven |
| Virtual Networking | Optional |
| Dedicated Compute & Reserved Cold Start | Optional (Always Ready) |
| Max Scale Out (Instances) | 1000 |
| Example AI Use Cases | Real-time data processing for AI models, high-traffic AI-powered APIs, event-driven AI microservices. Ideal for fraud detection, real-time recommendations, NLP, and computer vision services. |
Consumption
| Feature | Description |
|---|---|
| Scale to Zero | Yes |
| Scale Behavior | Event-driven |
| Virtual Networking | Optional |
| Dedicated Compute & Reserved Cold Start | No |
| Max Scale Out (Instances) | 200 |
| Example AI Use Cases | Lightweight AI APIs, scheduled AI tasks, low-traffic AI event processing. Great for sentiment analysis, simple image recognition, and batch ML tasks. |
Functions Premium
| Feature | Description |
|---|---|
| Scale to Zero | No |
| Scale Behavior | Event-driven with premium options |
| Virtual Networking | Yes |
| Dedicated Compute & Reserved Cold Start | Yes |
| Max Scale Out (Instances) | 100 |
| Example AI Use Cases | Enterprise AI applications, low-latency AI APIs, VNet integration. Ideal for secure, high-performance AI services like customer support and analytics. |
App Service
| Feature | Description |
|---|---|
| Scale to Zero | No |
| Scale Behavior | Dedicated VMs |
| Virtual Networking | Yes |
| Dedicated Compute & Reserved Cold Start | Yes |
| Max Scale Out (Instances) | Varies |
| Example AI Use Cases | AI-powered web applications, dedicated resources. Great for chatbots, personalized content, and intensive AI inference. |
Container Apps Env.
| Feature | Description |
|---|---|
| Scale to Zero | No |
| Scale Behavior | Containerized microservices environment |
| Virtual Networking | Yes |
| Dedicated Compute & Reserved Cold Start | Yes |
| Max Scale Out (Instances) | Varies |
| Example AI Use Cases | AI microservices architecture, containerized AI workloads, complex AI workflows. Ideal for orchestrating AI services like image processing, text analysis, and real-time analytics. |
Note
This example is using system-assigned managed identity to assign RBACs (Role-based Access Control).
-
Under
Settings, go toEnvironment variables. And+ Addthe following variables:-
COSMOS_DB_ENDPOINT: Your Cosmos DB account endpoint 🡢Review the existence of this, if not create it -
COSMOS_DB_KEY: Your Cosmos DB account key 🡢Review the existence of this, if not create it -
COSMOS_DB_CONNECTION_STRING: Your Cosmos DB connection string 🡢Review the existence of this, if not create it -
invoicecontosostorage_STORAGE: Your Storage Account connection string 🡢Review the existence of this, if not create it -
FORM_RECOGNIZER_ENDPOINT: For example:https://<your-form-recognizer-endpoint>.cognitiveservices.azure.com/🡢Review the existence of this, if not create it -
FORM_RECOGNIZER_KEY: Your Documment Intelligence Key (Form Recognizer). 🡢 -
FUNCTIONS_EXTENSION_VERSION:~4🡢Review the existence of this, if not create it -
WEBSITE_RUN_FROM_PACKAGE:1🡢Review the existence of this, if not create it -
FUNCTIONS_WORKER_RUNTIME:python🡢Review the existence of this, if not create it -
FUNCTIONS_NODE_BLOCK_ON_ENTRY_POINT_ERROR:true(This setting ensures that all entry point errors are visible in your application insights logs). 🡢Review the existence of this, if not create it
-
Click on
Applyto save your configuration.
-
-
You need to install VSCode
-
Install python from Microsoft store:
-
Open VSCode, and install some extensions:
python, andAzure Tools.
-
Click on the
Azureicon, andsign ininto your account. Allow the extensionAzure Resourcesto sign in using Microsoft, it will open a browser window. After doing so, you will be able to see your subscription and resources.
-
Under Workspace, click on
Create Function Project, and choose a path in your local computer to develop your function.
-
Choose the language, in this case is
python:
-
Select the model version, for this example let's use
v2:
-
For the python interpreter, let's use the one installed via
Microsoft Store:
-
Choose a template (e.g., Blob trigger) and configure it to trigger on new PDF uploads in your Blob container.
-
Provide a function name, like
BlobTriggerContosoPDFInvoicesDocIntelligence:
-
Next, it will prompt you for the path of the blob container where you expect the function to be triggered after a file is uploaded. In this case is
pdfinvoicesas was previously created.
-
Click on
Create new local app settings, and then choose your subscription.
-
Choose
Azure Storage Account for remote storage, and select one. I'll be using theinvoicecontosostorage.
-
Then click on
Open in the current window. You will see something like this:
-
Now we need to update the function code to extract data from PDFs and store it in Cosmos DB, use this an example:
- PDF Upload: A PDF file is uploaded to the Azure Blob Storage container (
pdfinvoices). - Trigger Azure Function: The upload triggers the Azure Function
BlobTriggerContosoPDFLayoutsDocIntelligence. - Initialize Clients: Sets up connections to Azure Document Intelligence and Cosmos DB.
- Initializes the
DocumentAnalysisClientusing theFORM_RECOGNIZER_ENDPOINTandFORM_RECOGNIZER_KEYenvironment variables. - Initializes the
CosmosClientusing Azure Active Directory (AAD) viaDefaultAzureCredential.
- Initializes the
- Read PDF from Blob Storage: Reads the PDF content from the blob into a byte stream.
- Analyze PDF: Uses Azure Document Intelligence to analyze the layout of the PDF.
- Calls
begin_analyze_documentwith theprebuilt-layoutmodel. - Waits for the analysis to complete and retrieves the layout result.
- Calls
- Extract Layout Data: Parses and structures the layout data from the analysis result.
- Extracts lines, tables, and selection marks from each page.
- Logs styles (e.g., handwritten content) and organizes data into a structured dictionary.
- Save Data to Cosmos DB: Saves the structured layout data to Cosmos DB.
- Ensures the database (
ContosoDBDocIntellig) and container (Layouts) exist or creates them. - Inserts or updates the layout data using
upsert_item.
- Ensures the database (
- Logging (Process and Errors): Logs each step of the process, including success messages and detailed error handling for debugging and monitoring.
-
Update the function_app.py, for example see the code used in each demo:
- Demo: Azure Implementation - PDF Layout Extraction with Azure AI Document Intelligence Supporting Multiple Document Versions with Visual Selection Cues (full-code approach)
- Demo: Automated PDF Invoice Processing with Open Framework (full-code approach)
- Demo: PDF Layout Extraction with Doc Intelligence (full-code approach)
- Demo: Automated PDF Invoice Processing with Doc Intelligence (full-code approach)
Template Blob Trigger Function Code updated 

-
Now, let's update the
requirements.txt, see the code used in each demo:- Demo: Azure Implementation - PDF Layout Extraction with Azure AI Document Intelligence Supporting Multiple Document Versions with Visual Selection Cues (full-code approach)
- Demo: Automated PDF Invoice Processing with Open Framework (full-code approach)
- Demo: PDF Layout Extraction with Doc Intelligence (full-code approach)
- Demo: Automated PDF Invoice Processing with Doc Intelligence (full-code approach)
Template requirements.txtUpdated requirements.txt

-
Since this function has already been tested, you can deploy your code to the function app in your subscription. If you want to test, you can use run your function locally for testing.
- PDF Upload: A PDF file is uploaded to the Azure Blob Storage container (
Important
If you need a hand with the code, just check out some of the examples, they’ve got extra information.
- Demo: Azure Implementation - PDF Layout Extraction with Azure AI Document Intelligence Supporting Multiple Document Versions with Visual Selection Cues (full-code approach)
- Demo: Automated PDF Invoice Processing with Open Framework (full-code approach)
- Demo: PDF Layout Extraction with Doc Intelligence (full-code approach)
- Demo: Automated PDF Invoice Processing with Doc Intelligence (full-code approach)



