Skip to content

Commit db08023

Browse files
committed
Update README with testing instruction
1 parent 24e1597 commit db08023

File tree

4 files changed

+48
-13
lines changed

4 files changed

+48
-13
lines changed

README.md

+36-10
Original file line numberDiff line numberDiff line change
@@ -142,27 +142,53 @@ To setup an environment in Azure, simply run the [Setup-Environment.ps1](./Setup
142142
143143
### Running the document processing pipeline
144144

145-
Once an environment is setup, you can run the document processing pipeline by uploading a batch of documents to the Azure Storage blob container and sending a message to the Azure Storage queue containing the container reference.
145+
Once an environment is setup, you can run the document processing pipeline by uploading a batch of documents to the Azure Storage blob container and sending a message via a HTTP request or Azure Storage queue containing the container reference.
146146

147-
> [!TIP]
148-
> Use the [Azure Storage Explorer](https://azure.microsoft.com/en-us/features/storage-explorer/) to upload the batch of documents to the Azure Storage blob container and send a message to the Azure Storage queue.
147+
A batch of invoices is provided in the tests [Invoice Batch folder](./tests/InvoiceBatch/) which can be uploaded into an Azure Storage blob container, locally via Azurite, or in the deployed Azure Storage account.
149148

150-
A batch of invoices is provided in the tests [Invoice Batch folder](./tests/InvoiceBatch/) which can be uploaded into an Azure Storage blob container.
149+
These files can be uploaded using the Azure VS Code extension or the Azure Storage Explorer.
150+
151+
![Azurite Local Blob Storage Upload](./assets/Local-Blob-Upload.png)
151152

152153
> [!NOTE]
153154
> Upload all of the individual folders into the container, not the individual files. This sample processed a container that contains multiple folders, each representing a customer's data to be processed which may contain one or more invoices.
154155
155-
Once uploaded, add the following message to the **invoices** queue in the Azure Storage account:
156+
#### Via the HTTP trigger
156157

157-
> [!IMPORTANT]
158-
> When running locally, the batch must be uploaded to the deployed Azure Storage account. However, the queue message must be created in the local development storage account, Azurite, running as a Docker container. You may need to create the **invoices** queue in the local storage account first via the Azure Storage Explorer.
158+
To send via HTTP, open the [`tests/HttpTrigger.rest`](./tests/HttpTrigger.rest) file and use the request to trigger the pipeline.
159+
160+
```http
161+
POST http://localhost:7071/api/invoices
162+
Content-Type: application/json
163+
164+
{
165+
"container_name": "invoices"
166+
}
167+
```
168+
169+
To run in Azure, replace `http://localhost:7071` with the `containerAppInfo.value.url` value from the [`./infra/apps/AIDocumentPipeline/AppOutputs.json`](./infra/apps/AIDocumentPipeline/AppOutputs.json) file after deployment.
170+
171+
#### Via the Azure Storage queue
172+
173+
To send via the Azure Storage queue, run the [`tests/QueueTrigger.ps1`](./tests/QueueTrigger.ps1) PowerShell script to trigger the pipeline.
174+
175+
This will add the following message to the **invoices** queue in the Azure Storage account, Base64 encoded:
159176

160177
```json
161178
{
162-
"container_name": "<container-name>"
179+
"container_name": "invoices"
163180
}
164181
```
165182

166-
![Azure Storage Explorer invoices queue](./assets/Azure-Storage-Explorer-Queue.png)
183+
To run in Azure, replace the `az storage message put` command with the following:
184+
185+
```powershell
186+
az storage message put `
187+
--content $Base64EncodedMessage `
188+
--queue-name "invoices" `
189+
--account-name "<storage-account-name>" `
190+
--auth-mode login `
191+
--time-to-live 86400
192+
```
167193

168-
The document processing pipeline will then be triggered, processing the batch of invoices and extracting the structured data from each invoice.
194+
The `--account-name` parameter should be replaced with the name of the Azure Storage account deployed in the environment found in the `storageAccountInfo.value.name` value from the [`./infra/InfrastructureOutputs.json`](./infra/InfrastructureOutputs.json) file after deployment.

assets/Local-Blob-Upload.png

53.7 KB
Loading

tests/HttpTrigger.rest

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# Start processing a batch of folders containing invoices within a Storage Container
2+
# Note: The following URL is for the local environment. To run in Azure, replace `http://localhost:7071` with the `containerAppInfo.value.url` value from the `./infra/apps/AIDocumentPipeline/AppOutputs.json` file.
13
POST http://localhost:7071/api/invoices
24
Content-Type: application/json
35

tests/QueueTrigger.ps1

+10-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
$LocalConnectionString = "AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;"
2-
31
$QueueMessage = @{
42
"container_name" = "invoices"
53
}
64

75
$Base64EncodedMessage = [Convert]::ToBase64String([System.Text.Encoding]::UTF8.GetBytes(($QueueMessage | ConvertTo-Json)))
86

7+
# Run on local
98
az storage message put `
109
--content $Base64EncodedMessage `
1110
--queue-name "invoices" `
12-
--connection-string $LocalConnectionString `
11+
--connection-string "AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;DefaultEndpointsProtocol=http;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;" `
1312
--time-to-live 86400
13+
14+
# Run on Azure
15+
# az storage message put `
16+
# --content $Base64EncodedMessage `
17+
# --queue-name "invoices" `
18+
# --account-name "<storage-account-name>" `
19+
# --auth-mode login `
20+
# --time-to-live 86400

0 commit comments

Comments
 (0)