Recently I
have been working with the blob storage where in many cases I had to move,
copy, and delete the blob from the storage after performing some actions on
those blobs. In this blog I am going to talk about how to perform copy, move,
delete operation on Azure blob storage from the Logic APP.
This is
quite simple to perform these operations as Logic App provides these inbuild
function so all we need to do is to call relevant function for a particular
requirement.
Requirement:
In my requirement I had to read the file content from the boob storage and
after reading it I had to move it to different blob storage and in some scenario,
I had to delete it permanently from the blob storage. So, let’s see how we can achieve
it.
Create A Logic APP:
This first
step is obviously creating a Logic App. If you want to see how to create from
scratch, then please follow my previous blog.
You can use any trigger as this in totally independent functionality.
Create a Connection:
After
creating a logic app and trigger, you have to make a connection to the Azure
blob (if you dint have already). You need to provide your credentials to create
connection.
Azure Blob inbuilt function:
When you choose “Azure Blob” as “+ New Step” and after creating a connection with blob, you can see multiple option Azure Logic App provides for use to use. You can see in below screenshot where you can choose Create Blob, Copy blob, delete blob etc.
Copy Blob:
Copying
blob functionality can be achieved by specifying Source URL and Destination URL.
In below example I have given dynamic values as this is the common pattern, we
use otherwise you can use a static one.
In below screenshot you can see how the dynamic URL is generated after running the Logic APP. This is something we can also provide as static value.
Delete Blob:
This is
also one of the inbuilt functions provided by the logic app to play with Azure
blob. Simply use the Delete blob from the option and provide the blob path
which you want to delete. Below is the dynamic one.
Dynamic one will be changed to below URL if we run this app.
Move Blob from one to another folder:
There is no
functionality like that but what we can do to achieve it to simply copy first
from source to destination folder and then perform delete operation in the
source folder to delete the blob
No comments:
Post a Comment