How to create an invoice template - azure-logic-apps

Not sure if this is even possible, but what I'm looking to do create an invoice template via some SQL output and send them out as emails.
What I have tried so far is run a piece of SQL that contains all the details of an invoice, parse it as JSON, then create a csv table and lastly send them out via email with a CSV as an attachment.
The issue that I'm facing is that it's pretty basic; I would like to create a template of sorts and later converted to a PDF.
I'm moving away from SSRS and trying to use a logic app for the first time so not sure if this is something even achievable.
Appreciate any tips/help. Thanks in advance.
Regards

One way to achieve this is to use to Create CSV table with Custom Headers from Sql connector Get rows (V2) action and then convert it to Excel using 3rd party connector Plumsail's Csv to Excel action to transform the results of it into pdf using Convert Excel to PDF action of Adobe PDF services Connector.
Below is the flow of my logic app where I receive a sorted csv's pdf in my email attachments.
RESULTS:
TABLE IN SQL DATABASE
RESULT IN LOGIC APP
RESULT IN MAIL
To reproduce the same in your logic app, you can use below code view
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Convert_Excel_to_PDF": {
"inputs": {
"body": {
"$content-type": "multipart/form-data",
"$multipart": [
{
"body": "EXCEL_TO_PDF",
"headers": {
"Content-Disposition": "form-data; name=\"intent\""
}
},
{
"body": "pdfFile.xlsx",
"headers": {
"Content-Disposition": "form-data; name=\"inputFileName\""
}
},
{
"body": "#body('Csv_to_Excel')",
"headers": {
"Content-Disposition": "form-data; name=\"InputFile0\""
}
}
]
},
"headers": {
"x-api-key": "PowerAutomate"
},
"host": {
"connection": {
"name": "#parameters('$connections')['adobepdftools']['connectionId']"
}
},
"method": "post",
"path": "/operation/v1/createPDFFromExcel"
},
"runAfter": {
"Csv_to_Excel": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Create_CSV_table": {
"inputs": {
"columns": [
{
"header": "BillNo",
"value": "#item()?['billNo']"
},
{
"header": "OrderedDate",
"value": "#item()?['orderedDate']"
},
{
"header": "OrderValue",
"value": "#item()?['orderValue']"
}
],
"format": "CSV",
"from": "#body('Get_rows_(V2)')?['value']"
},
"runAfter": {
"Get_rows_(V2)": [
"Succeeded"
]
},
"type": "Table"
},
"Csv_to_Excel": {
"inputs": {
"body": {
"content": "#{base64(body('Create_CSV_table'))}",
"hasHeaderRecords": true
},
"host": {
"connection": {
"name": "#parameters('$connections')['plumsail_3']['connectionId']"
}
},
"method": "post",
"path": "/flow/v1/Documents/jobs/Csv2Xlsx"
},
"runAfter": {
"Create_CSV_table": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"Get_rows_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['sql']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/#{encodeURIComponent(encodeURIComponent('default'))},#{encodeURIComponent(encodeURIComponent('default'))}/tables/#{encodeURIComponent(encodeURIComponent('[dbo].[Invoices]'))}/items",
"queries": {
"$orderby": "billNo asc"
}
},
"runAfter": {},
"type": "ApiConnection"
},
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Attachments": [
{
"ContentBytes": "#{body('Convert_Excel_to_PDF')?['fileContent']}",
"Name": "#body('Convert_Excel_to_PDF')?['fileName']"
}
],
"Body": "<p>This is a sample email</p>",
"Importance": "Normal",
"Subject": "Sample",
"To": "<TO_MAIL_ID>"
},
"host": {
"connection": {
"name": "#parameters('$connections')['office365_1']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Convert_Excel_to_PDF": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"evaluatedRecurrence": {
"frequency": "Minute",
"interval": 3
},
"recurrence": {
"frequency": "Minute",
"interval": 3
},
"type": "Recurrence"
}
}
},
"parameters": {
"$connections": {
"value": {
"adobepdftools": {
"connectionId": "/subscriptions/<SUB_ID>/resourceGroups/<RG>/providers/Microsoft.Web/connections/adobepdftools-4",
"connectionName": "adobepdftools-4",
"id": "/subscriptions/<SUB_ID>/providers/Microsoft.Web/locations/centralus/managedApis/adobepdftools"
},
"office365_1": {
"connectionId": "/subscriptions/<SUB_ID>/resourceGroups/<RG>/providers/Microsoft.Web/connections/office365-1",
"connectionName": "office365-1",
"id": "/subscriptions/<SUB_ID>/providers/Microsoft.Web/locations/centralus/managedApis/office365"
},
"plumsail_3": {
"connectionId": "/subscriptions/<SUB_ID>/resourceGroups/<RG>/providers/Microsoft.Web/connections/plumsail-3",
"connectionName": "plumsail-3",
"id": "/subscriptions/<SUB_ID>/providers/Microsoft.Web/locations/centralus/managedApis/plumsail"
},
"sql": {
"connectionId": "/subscriptions/<SUB_ID>/resourceGroups/<RG>/providers/Microsoft.Web/connections/sql",
"connectionName": "sql",
"id": "/subscriptions/<SUB_ID>/providers/Microsoft.Web/locations/centralus/managedApis/sql"
}
}
}
}
}

Related

I am able to set up to receive emails, but I am unable to upload attachments to onedrive. Please tell me how to upload the file

I want to store a specific Excel file attached to an email I receive in outlook in a specific folder in onedrive.
(I have the process to store the file in blob, but I want to process the Excel file, so I am thinking of saving it once in onedrive.)
I am able to set up to receive emails, but I am unable to upload attachments to onedrive. Please tell me how to upload the file.
The contents of the Excel file, but there are multiple sheets.
The json looks like this. (partially hidden)
{
"id": "/subscriptions/XXXXXXXX/resourceGroups/XXXXXXXX/providers/Microsoft.Web/sites/test/workflows/excel_test2",
"name": "test/excel_test2",
"type": "Microsoft.Web/sites/workflows",
"kind": "Stateful",
"location": "XXXXXXXX",
"properties": {
"files": {
"workflow.json": {
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"Update_file": {
"inputs": {
"body": "#base64ToBinary(items('For_each')?['contentBytes'])",
"host": {
"connection": {
"referenceName": "onedriveforbusiness"
}
},
"method": "put",
"path": "/datasets/default/files/#{encodeURIComponent(encodeURIComponent('filebox\\raw\\*.xlsm'))}"
},
"runAfter": {
"Getting Attachments_(V2)": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"Getting Attachments_(V2)": {
"inputs": {
"host": {
"connection": {
"referenceName": "office365"
}
},
"method": "get",
"path": "/codeless/v1.0/me/messages/#{encodeURIComponent(triggerBody()?['id'])}/attachments/#{encodeURIComponent(items('For_each')?['id'])}"
},
"runAfter": {},
"type": "ApiConnection"
}
},
"foreach": "#triggerBody()?['attachments']",
"runAfter": {},
"type": "Foreach"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"When you receive a new email_(V3)": {
"inputs": {
"fetch": {
"method": "get",
"pathTemplate": {
"template": "/v3/Mail/OnNewEmail"
},
"queries": {
"fetchOnlyWithAttachment": true,
"folderPath": "Id::XXXXXXXX=",
"importance": "Any",
"includeAttachments": true
}
},
"host": {
"connection": {
"referenceName": "office365"
}
},
"subscribe": {
"body": {
"NotificationUrl": "#{listCallbackUrl()}"
},
"method": "post",
"pathTemplate": {
"template": "/GraphMailSubscriptionPoke/$subscriptions"
},
"queries": {
"fetchOnlyWithAttachment": true,
"folderPath": "Id::XXXXXXXX=",
"importance": "Any"
}
}
},
"metadata": {
"Id::XXXXXXXX=": "XXXXXXXX_1"
},
"splitOn": "#triggerBody()?['value']",
"type": "ApiConnectionNotification"
}
}
},
"kind": "Stateful"
}
},
"flowState": 2,
"health": {
"state": 1
}
}
}
One way to achieve your requirement is to create a file in OneDrive with the same name as you are receiving from outlook. Below is the flow of my logic app.
Below is the mail I'm receiving in my outlook
RESULTS:
Results in Logic Apps
Results in One drive

Azure Logic apps - output array in email body

I have trouble using my array variable in my V2 email in Logic apps. I would like to output my array in the email body. For example if my array is ["1","2",3"]. Im want each value on its own row.
1
2
3
I have 2 issues, outputting my array in the email body(only strings showing in the dynamic menu) and making each value on a row.
After reproducing from my end, I could able to achieve your requirement by replacing "," with "< br>< br>" while sending the email using Send an email (V2) action. Below is the expression that worked for me.
replace(string(variables('SampleArray')),',','<br><br>')
Here is the flow of my Logic App
Result in my Inbox:
To reproduce the same, you can use below codeview in your logicapp
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"SampleArray": {
"inputs": {
"variables": [
{
"name": "SampleArray",
"type": "array",
"value": [
1,
2,
3
]
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Body": "<p>#{replace(string(variables('SampleArray')),',','<br><br>')}</p>",
"Importance": "Normal",
"Subject": "Sample",
"To": "<YOUR-EMAIL>"
},
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"operationOptions": "DisableAutomaticDecompression",
"runAfter": {
"SampleArray": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {
"schema": {}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"office365": {
"connectionId": "/subscriptions/<SUB-ID>/resourceGroups/<RG>/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/<SUB-ID>/providers/Microsoft.Web/locations/centralus/managedApis/office365"
}
}
}
}
}

How to display array in Slack Webhook of Azure Logic Apps?

I have LogicApps. It receives property ListOfNames array in HTTP request.
I have difficulty to display correctly in Slack webhook. How to format body?
Current message displayed in Slack:
ListOfNames:
["Name1 \n","Name2\n","Name3\n"]
Target message in slack:
ListOfNames:
Name1
Name2
Name3
I tried Split:
Code: No errors, but don't array items listed correctly in message:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": "#split(string(triggerBody()?['ListOfTesNames']),'\\n') ",
"runAfter": {},
"type": "Compose"
},
"HTTP_Webhook": {
"inputs": {
"subscribe": {
"body": {
"blocks": [
{
"text": {
"text": "*[dev] Testing:* \n ListOfTestNames #{outputs('Compose')} ",
"type": "mrkdwn"
},
"type": "section"
},
{
"text": {
"text": "Please check test results from database ",
"type": "mrkdwn"
},
"type": "section"
}
]
},
"method": "POST",
"uri": "https://hooks.slack.com/services/1111111111111111111111"
},
"unsubscribe": {}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"runtimeConfiguration": {
"staticResult": {
"name": "HTTP_Webhook0",
"staticResultOptions": "Disabled"
}
},
"type": "HttpWebhook"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"staticResults": {
"HTTP_Webhook0": {
"outputs": {
"headers": {},
"statusCode": "OK"
},
"status": "Succeeded"
}
},
"triggers": {
"manual": {
"inputs": {
"method": "POST",
"schema": {
"properties": {
"ListOfTestNames": {
"type": "array"
}
},
"type": "object"
}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}
You can add a compose connector before the webhook connector and use split functionality which gives the right format and then add the output of the compose connector to your webhook connector.
Here is a screenshot for your reference:
Note: Make sure you modify the expression in your split from compose connector as split(triggerBody()?['ListOfFiles'],'\n') to split(triggerBody()?['ListOfFiles'],'\n') because when we write the expression for this, it first takes '\n' as a string and then adds another ''.
Below is the split expression in compose connector:
split(triggerBody()?['ListOfFiles'],'
')
Updated Answer
As we are retrieving an array and passing it to the body of text it is adding the extra characters to it. We have created a new Logic App and added each item that we are retrieving to a variable and finally added that variable to the Webhook body.
Here is the screenshot of the logic app
Here is my code view
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"For_each": {
"actions": {
"For_each_2": {
"actions": {
"Append_to_string_variable": {
"inputs": {
"name": "ListOfFilesFinal",
"value": "#{items('For_each_2')},"
},
"runAfter": {},
"type": "AppendToStringVariable"
}
},
"foreach": "#split(item(),',')",
"runAfter": {},
"type": "Foreach"
}
},
"foreach": "#triggerBody()?['ListOfFiles']",
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "Foreach"
},
"HTTP_Webhook": {
"inputs": {
"subscribe": {
"body": {
"blocks": [
{
"text": {
"text": "*[dev] Testing: * \n ListOfTestNames : #{variables('ListOfFilesFinal')} ",
"type": "mrkdwn"
},
"type": "section"
},
{
"text": {
"text": "Please check test results from database ",
"type": "mrkdwn"
},
"type": "section"
}
]
},
"method": "POST",
"uri": "#listCallbackUrl()"
},
"unsubscribe": {}
},
"runAfter": {
"For_each": [
"Succeeded"
]
},
"runtimeConfiguration": {
"staticResult": {
"name": "HTTP_Webhook0",
"staticResultOptions": "Disabled"
}
},
"type": "HttpWebhook"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "ListOfFilesFinal",
"type": "string"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"staticResults": {
"HTTP_Webhook0": {
"outputs": {
"headers": {},
"statusCode": "OK"
},
"status": "Succeeded"
}
},
"triggers": {
"manual": {
"inputs": {
"method": "POST",
"schema": {
"properties": {
"ListOfFiles": {
"type": "array"
}
},
"type": "object"
}
},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {}
}

'Send an Email' parameter 'attachment content' cannot be null

I'm creating an Azure Logic App to email a CSV file with data. When there is no data, the Send_an_email_(V2) step is failing and I see the following error in its output:
Parameter 'Attachment Content' cannot be null or empty.
The Send_an_email_(V2) action in the Azure Logic App gets part of it's input from the output of a preceding Create_CSV_table action. It uses the body of the Create_CSV_table output as shown below, in order to construct ContentBytes for an email attachment:
"actions": {
"Create_CSV_table": {
"inputs": {
"format": "CSV",
"from": "#body('Parse_JSON')"
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Table"
},
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Attachments": [
{
"ContentBytes": "#{base64(body('Create_CSV_table'))}",
"Name": "report.csv"
}
],
"Body": "<p></p>",
"Subject": "My Report",
"To": "me#email.com"
},
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Create_CSV_table": [
"Succeeded"
]
},
"type": "ApiConnection"
}
When there is no data input into the Create_CSV_table step, the Create_CSV_table step is successful, and the raw output for the Create_CSV_table step shows an empty body as follows:
{
"body": ""
}
Raw input for the failing Send_an_email_(V2) step
{
HTTP stuff ...,
"body": {
"Attachments": [
{
"ContentBytes": "",
"Name": "report.csv"
}
],
"Body": "<p></p>",
"Subject": "Report",
"To": "me#mail.com"
}
}
Raw output for the failing Send_an_email_(V2) step
{
HTTP stuff ...,
"body": {
"status": 400,
"message": "Parameter 'Attachment Content' cannot be null or empty.\r\nclientRequestId: 887e3968-c7e9-4c35-b588-f76fd0e51545",
"error": {
"message": "Parameter 'Attachment Content' cannot be null or empty."
},
"source": "office365-ase.azconn-ase.p.azurewebsites.net"
}
}
How do I handle this? Do I need to implement my own null handling for the "ContentBytes" of the Send_an_email_(V2) input? If so, how do I do that? Or is there another way to handle this. I want an empty email to be sent when there is no CSV content.
I figured out that #{base64(body('Create_CSV_table'))} is an Azure Logic Apps expression (denoted by #), containing functions that act on the JSON for the body of the output of Create_CSV_table and that the enclosing {} results in the output of the expression being a string.
After the Last step you can send to storage account using Create blob(V2) Connection with .csv file extension and then send the same blob content using Get blob content(V2) Connection then Send an email.
Here are the screenshots of LogicApp
In outlook:
Here is the workflow
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Create_CSV_table_2": {
"inputs": {
"format": "CSV",
"from": "#variables('Array')"
},
"runAfter": {
"For_each_2": [
"Succeeded"
]
},
"type": "Table"
},
"Create_blob_(V2)": {
"inputs": {
"body": "#body('Create_CSV_table_2')",
"headers": {
"ReadFileMetadataFromServer": true
},
"host": {
"connection": {
"name": "#parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "post",
"path": "/v2/datasets/#{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files",
"queries": {
"folderPath": "/ch1container2408",
"name": "TestSample1.csv",
"queryParametersSingleEncoded": true
}
},
"runAfter": {
"Create_CSV_table_2": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"For_each_2": {
"actions": {
"Append_to_array_variable": {
"inputs": {
"name": "Array",
"value": {
"created_at": "#items('For_each_2')['created_at']",
"funds": "#items('For_each_2')['funds']",
"id": "#items('For_each_2')['id']",
"pair": "#items('For_each_2')['market']",
"price": "#items('For_each_2')['price']",
"side": "#items('For_each_2')['side']",
"volume": "#items('For_each_2')['volume']"
}
},
"runAfter": {},
"type": "AppendToArrayVariable"
}
},
"foreach": "#body('Parse_JSON')",
"runAfter": {
"Initialize_variable_2": [
"Succeeded"
]
},
"type": "Foreach"
},
"Get_blob_content_(V2)": {
"inputs": {
"host": {
"connection": {
"name": "#parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "get",
"path": "/v2/datasets/#{encodeURIComponent(encodeURIComponent('AccountNameFromSettings'))}/files/#{encodeURIComponent(encodeURIComponent('/<Your Container>','/<Your File>.csv'))}/content",
"queries": {
"inferContentType": true
}
},
"runAfter": {
"Create_blob_(V2)": [
"Succeeded"
]
},
"type": "ApiConnection"
},
"HTTP": {
"inputs": {
"method": "GET",
"uri": "https://api.wazirx.com/api/v2/trades?market=btcusdt"
},
"runAfter": {},
"type": "Http"
},
"Initialize_variable": {
"inputs": {
"variables": [
{
"name": "Array",
"type": "array"
}
]
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Initialize_variable_2": {
"inputs": {
"variables": [
{
"name": "Table",
"type": "array"
}
]
},
"runAfter": {
"Initialize_variable": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"Parse_JSON": {
"inputs": {
"content": "#body('HTTP')",
"schema": {
"items": {
"properties": {
"created_at": {
"type": "string"
},
"funds": {
"type": "string"
},
"id": {
"type": "integer"
},
"market": {
"type": "string"
},
"price": {
"type": "string"
},
"side": {},
"volume": {
"type": "string"
}
},
"required": [
"id",
"market",
"price",
"volume",
"funds",
"created_at",
"side"
],
"type": "object"
},
"type": "array"
}
},
"runAfter": {
"HTTP": [
"Succeeded"
]
},
"type": "ParseJson"
},
"Send_an_email_(V2)": {
"inputs": {
"body": {
"Attachments": [
{
"ContentBytes": "#{base64(body('Get_blob_content_(V2)'))}",
"Name": "#body('Create_blob_(V2)')?['Name']"
}
],
"Body": "<p>TABLE TEST</p>",
"Subject": "Test",
"To": "<To Address>"
},
"host": {
"connection": {
"name": "#parameters('$connections')['office365']['connectionId']"
}
},
"method": "post",
"path": "/v2/Mail"
},
"runAfter": {
"Get_blob_content_(V2)": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "<Your ConnectionId>",
"connectionName": "azureblob",
"id": "<Id>"
},
"office365": {
"connectionId": "<Your ConnectionId>",
"connectionName": "office365",
"id": "<Your Id>"
}
}
}
}
}

valid HTTP connector, valid Blob connector but no file downloads?

I have a URL that points to a ZIP file and I want to have a logic app that takes that ZIP file and downloads it to a blob.
I've created an HTTP action with GET as the method and validated the URL is accurate and the payload (a ZIP file) downloads as expected when I browse to the URL. No other data is in the HTTP action.
I've created an Azure blob storage action that I've confirmed can receive data.
I cannot seem to figure out the syntax to actually connect the HTTP action to download the approximately 3MB ZIP file to the Azure blob storage. I've tried every combination of dynamic inputs but something isn't working.
Code with confidential keys and identifying details removed:
{
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/XXX/resourceGroups/Default-SQL-CentralUS/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"id": "/subscriptions/XXX/providers/Microsoft.Web/locations/centralus/managedApis/azureblob"
}
}
},
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Create_blob": {
"inputs": {
"body": "#variables('fileAccessURL')",
"headers": {
"Content-Type": "application/octet-stream"
},
"host": {
"connection": {
"name": "#parameters('$connections')['azureblob']['connectionId']"
}
},
"method": "post",
"path": "/datasets/default/files",
"queries": {
"folderPath": "/validis",
"name": "logicapptest",
"queryParametersSingleEncoded": true
}
},
"runAfter": {
"DownloadZIP": [
"Succeeded"
]
},
"runtimeConfiguration": {
"contentTransfer": {
"transferMode": "Chunked"
}
},
"type": "ApiConnection"
},
"DownloadZIP": {
"inputs": {
"method": "GET",
"uri": "#variables('fileAccessURL')"
},
"operationOptions": "DisableAutomaticDecompression",
"runAfter": {
"SetFileAccessURL": [
"Succeeded"
]
},
"type": "Http"
},
"InitializeAccessToken": {
"inputs": {
"variables": [
{
"name": "access_token",
"type": "String"
}
]
},
"runAfter": {},
"type": "InitializeVariable"
},
"InitializeFileAccessURL": {
"inputs": {
"variables": [
{
"name": "fileAccessURL",
"type": "String"
}
]
},
"runAfter": {
"InitializeAccessToken": [
"Succeeded"
]
},
"type": "InitializeVariable"
},
"POST-AuthKey": {
"inputs": {
"body": "grant_type=vapi_key&key=XXX",
"headers": {
"Content-Type": "application/x-www-form-urlencoded",
"Ocp-Apim-Subscription-Key": "XXX",
"cache-control": "no-cache"
},
"method": "POST",
"uri": "https://api.sandbox.XXX.com/v1/oauth/token"
},
"runAfter": {
"InitializeFileAccessURL": [
"Succeeded"
]
},
"type": "Http"
},
"RetrieveZIP_URL": {
"inputs": {
"headers": {
"Authorization": "#{concat('Bearer ',variables('access_token'))}",
"Ocp-Apim-Subscription-Key": "XXX",
"cache-control": "no-cache"
},
"method": "GET",
"uri": "https://api.sandbox.XXX.com/v1/extracts/general-ledger/engagements/XXX"
},
"runAfter": {
"SetAccessToken": [
"Succeeded"
]
},
"type": "Http"
},
"SetAccessToken": {
"inputs": {
"name": "access_token",
"value": "#{body('POST-AuthKey').access_token}"
},
"runAfter": {
"POST-AuthKey": [
"Succeeded"
]
},
"type": "SetVariable"
},
"SetFileAccessURL": {
"inputs": {
"name": "fileAccessURL",
"value": "#{body('RetrieveZIP_URL').fileaccessurl}"
},
"runAfter": {
"RetrieveZIP_URL": [
"Succeeded"
]
},
"type": "SetVariable"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {
"$connections": {
"defaultValue": {},
"type": "Object"
}
},
"triggers": {
"Recurrence": {
"recurrence": {
"frequency": "Month",
"interval": 12
},
"type": "Recurrence"
}
}
}
}

Resources