You are on page 1of 15

# Description Component/Service

1 Microsoft SQL Database View provided by Cotton on team SQL Server (On-premises)

2 Power Platform On-premises Date Gateway On-premises Data Gateway

3 Power Platfrom Dataflow is scheduled to trigger every 30 Dataflow


minutes to import data from on-premises SQL Server into
Dataverse. Data will be imported into two tables. Data import
is an incremental data import based on the column
(automation_insert_utc_datetime). Power Query will create a
GUID for each data import. This GUID will will be stores in
DataImportID column in the UniquieId Table. Each Purchase
Order will be mapped to the GUID.
Once the Dataflow is completed, it will trigger the Power
Automate Flow [5]

4 Dataverse entities Dataverse


Imported data from Dataflow will be added into the Dataverse
tables. Solution uses 3 Dataverse tables.

5 Dataflow will trigger the Power Automate Flow once it's Power Automate Flow
completed. Then it will add a JSON message into the Azure
storage queue [6]. The JSON message will only contain the
message type, GUID and the data import status.
Another copy of the message will be added to the queue [15]
to capture the journey of the PO in Application Insight.

6 Power Automate Flow [5] will add a JSON message into the Storage Queue
Storage Queue [6].
Whan a message is added to this queue, Azure Function [7] will
trigger.

7 Azure Function Azure Function


This function will trigger when a message is added to the
Queue [6].
This Function will:
• connect to Dataverse and query all the Purchase Orders
where the StatusID is empty and relavant data required to
generate OPs.
• For each PO it will add a message to the storage blob [8] and
a related message to the queue [9].
• Add a status message to Queue [15]

8 A JSON Message with all PO data required to generate all 3 Storage Blob
files is added to this blob, by Azure Function [7]. One message
for each PO.
9 A JSON message is added to this queue by Azure Function [7]. Storage Queue
The message will have the referance to the relavant message
in the blob storage [8] with all PO data to process the PO.
When a message is added to this queue, the Azure Function
[10] will trigger.

10 Azure Function Azure Function


This is triggered when a message is added to the Queue [9]. It
will read the message, with the URL property it will fetch the
relevant message with PO information in storage blob [8], and
process.
This Function will:
• Generate the HTML for the PO and convert the HTML to PDF.
• Store the PDF in SharePoint.
• Generate the CSV of the PO data.
• Store the CSV in SharePoint Online
• Generate the Excel file
• Store the Excel in SharePoint.
• Delete the message from blob storage
• Add a message to queue [11]
• Add a status message to Queue [15]

11 A JSON message is added to this queue by Azure Function [10]. Storage Queue
The message will have adequate informtaion to send an email
to the supplies and the buyer. Also the message will contain
the SharePoint URL to the 3 files that will be attached to the
mail.

12 This Azure Function [12] gets triggered when a message is Azure Function
added to storage queue [11].
This function will:
• Create an email based on the given template.
• Attache 3 files [PDF, CSV, Excel] relavant to the PO
• Send the email to the supplier and the buyer
• Add a message to queue [13]
• Add a message to queue [15]

13 A JSON message is added to this queue by Azure Function [12]. Storage Queue
The message will contain information to update the
PurchareOrderStatus table for audit purposes and delete all
records relared to PO from PurchaseOrder table.

14 This Azure Function [14] gets triggered when a message is Azure Function
added to storage queue [13].
This function will:
• Update the PurchaseOrder status table's column StatusId
with the current status of the PO. Status could be completed
or failed.

15 When a message is added to this queue it will be processed by Storage Queue


Azure Function [16]. The Power Automate and all 4 Azure
Functions [7, 10, 12, 14] will add JSON messages to this queue.
16 This Azure Function will trigger when a message is added to Azure Function
queue [15].
Function will:
• Read the message and write the necessary information to
Application Insight.

17 Service Principal service principal

18 SharePoint Site Collection is used to store the store files SharePoint Site Collection
generated by Azure Function [10]. For each PO, 3 files will be
generated and stored in the Document Library in the given Site
Collection

Azure resource group. This will contain all Azure resources


related to the solution.

Azure Storage Account. This will contain 4 Azure stoareg


Queues [12, 14, 15,16] and 1 Azure storage blob [13].

Azure Storage Blob


Azure Function [8] would add a message for each PO that
needs to be processed. The message is a JSON message and
will contain all the necessary data that needs to generate the
PO and the CSV and the Excel file.

Azure Function App which will automate the PO generation


and sending the email to suppliers.
This Funcation app contains 4 Azure Functions [7, 10, 12, 14]

Azure Subscription Subscription


Dev
View name:
• vw_ct_supplier_po_automation

User account with read only access to the UAT


Database.
• cotton-on\serv_podoc_b

Gateway name:
• uat-b-datagwy01-a
Incremental import column:
• automation_insert_utc_datetime

Table names:
• PurchaseOrderStatus
• PurchaseOrder
• ProcessStatus
Report name:
<Style Number>|| – ||<Order Number>|| – ||
<Reference>|| – Purchase Order’.pdf
Application ID (Client ID): ef6088dd-0550-4d66-bcb2-
fcad4abe5bff
Client Secret:
3lQ8Q~sNlvkuH1Ik7UBf0CXrCYbcXoZZ_hLXIb4M

Site Collection URL:



https://cottononcomau.sharepoint.com/sites/Purchas
eOrderDocumentation

Document Library:

Resourec Group name:


• rg-poautomation-dev-aueast

COG - Integration - Dev/Test


Prod
View name:
• vw_ct_supplier_po_automation

User account with read only access to the UAT Database.


• cotton-on\serv_podoc

Pending:

Incremental import column:


• automation_insert_utc_datetime

Table names:
• PurchaseOrderStatus
• PurchaseOrder
• ProcessStatus
Report name:
<Style Number>|| – ||<Order Number>|| – ||
<Reference>|| – Purchase Order’.pdf
Application ID (Client ID): ef6088dd-0550-4d66-bcb2-
fcad4abe5bff
Client Secret:
3lQ8Q~sNlvkuH1Ik7UBf0CXrCYbcXoZZ_hLXIb4M

Site Collection URL:



https://cottononcomau.sharepoint.com/sites/PurchaseOrd
erDocumentation

Document Library:

Resourec Group name:


• rg-poautomation-prod-XXXX

COG - Integration - Production


Additional Information

Sample message added to queue [12]:

{
"MessageType":"DataFlow",
"GUID":"4e58e818-94b1-4795-b36c-9c856c2559e6",
"Import Status":"Completed"
}

Servcie account to execute the Power Automate Flow:


• serv_podoc@cottonon.com.au

Create a container for each data import.


Client secret expires on 27/07/2025

API access granted to SharePoint Online


Dataverse access given to custom role: PO Automation App

Each PO will have a Unique name:


[OrderNumber]-[ReferenceNumber]

You might also like