Automate Document Storage with Azure AI Agents & Logic AppsAutomate Document Storage with Azure AI Agents & Logic Apps
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started
Recently I was experimenting with AI agents in Azure AI Foundry and built a workflow where an AI agent can generate and store documents automatically.
The idea was straightforward: When a user asks for a document, the agent generates the document content and file name, then triggers an Azure Logic App to create and store the file in Azure Blob Storage under a specific folder identified by a folder ID.
The Logic App is exposed through an HTTP trigger and registered as an action/tool for the agent. Once the agent has the required information (file name, folder ID, and document content), it calls this action to create the document.
Agent Action Instructions The agent is instructed to call the tool when a user asks to create a document. The request must include:
folderId fileName (with extension such as .docx) content (full document text) After execution, the system responds confirming that the document was saved.
Logic App Flow (Word Document Case) One challenge I ran into was that you cannot simply create a blob with a .docx extension and expect it to behave like a real Word file. Doing so results in a corrupted document that cannot be opened properly.
To solve this, the Logic App performs the following steps:
Extension Detection
A switch statement checks the file extension:
@{toLower(last(split(variables('fileName'), '.')))} 2. Generate Word File
For .docx files, the Logic App uses the action:
Create a Microsoft Word document with the given content (OneDrive)
This generates a temporary Word file.
Download File Content
The action returns a download URL, not the file content itself. An HTTP GET request is then used to retrieve the file.
Convert Content
The returned content is converted from Base64 to binary:
@{base64ToBinary(body('HTTP_get_file_content')?['$content'])} 5. Cleanup Temporary File
Since the Word document was created temporarily in OneDrive:
The Logic App lists files in the root folder Filters the file by name Retrieves its ID Deletes it using the Delete file action 6. Store in Azure Blob Storage
Finally, the binary content is saved using Create Blob (V2):
Folder path derived from the folderId File name from the agent File content from the converted binary Response The Logic App returns a confirmation response once the document is stored:
{   "status": "success",   "message": "Document saved successfully",   "folderId": "...",   "fileName": "..." } Why this approach matters This workflow demonstrates a practical pattern for AI-driven document automation:
The AI agent generates document content and file names Azure Logic Apps orchestrate the document creation Azure Blob Storage stores the final document in a structured folder It’s a simple but effective way to connect AI-generated content with production storage workflows.
Next step: extending the workflow to support PDF generation as well.
Would be interesting to see how others are integrating AI agents with Logic Apps or automated document pipelines.
Back to feed
The network for creativity
Join 1.25M professional creatives like you
Connect with clients, get discovered, and run your business 100% commission-free
Creatives on Contra have earned over $150M and we are just getting started