 Hey guys welcome to SSUnitex which is this side and today we are going to start with the area of interview questions and answers and this question is very common interview question. So we want to delete the file those are more than 30 days old for any folder. So let me quickly go into the Azure Blob Store and we will see. So here as we can see here the first file which is the sales India file and the date that we can see the modified date which is 14th of August 2022. So if we can check for today's date then we can see like the today's date which is the 5th of September. So instead of deleting the file which is more than 30 days here I am going to delete the file which is more than 20 days. So we will see how we can delete all those. So the file which is more than 20 days which is the first one, third one and the fifth one. So these three files should be deleted from this folder. So let me quickly go into the Azure Data Factory and here first let me try to add a new pipeline and let me call this pipeline as delete 20 days old files. Now here we are going to use the get meta data activity first because we are required to check all the files those are available under this testing folder. So here under this get meta data activity now here one thing we can notice we are getting this information. So previously remember the timeout was very long which is for 7 days but now that is reduced by default from 7 days to 12 hours. So that's why it is indicating if you want to run your activity and which is taking more than 12 hours then we can reset from here. So that is okay. Let me quickly go into the setting and here we need to create a new data set and which is pointing the Azure Blob Storage and the file will be the delimited text. Here we can select the link service and after that we can click on this browse and go to the testing folder. So under this folder whatever the files are available we need to get all the files. After that we can click on okay. So we have successfully set up for the source. Now we need to use the for each container and that for each container will be processing all these files one by one. So we have to use the for each activity. So we can drag and drop the for each activity here. We can connect with this get meta data activity. So what is our plan? Our plan is here in the get meta data activity first we will be getting all these files and we can get all these files we have to add inside the field list as a new and here we can select the child items. So it will be processing all these files and by using for each activity will be loop through each files. So what we will do? We will be going to process all these files and after that getting the file name and the last modified date. So we cannot get the last modified date directly under this get meta data activity because it will be indicating the last modified of the folder. So that's why we have to use the get meta data activity for processing one by one file and under the for each again we have to use the get meta data activity. So let me use the get meta data activity and this get meta data activity too will be going to take the file name from the for each container. So let me try to create a new data set here and this is again pointing to as your blog stories delimited text file and here we can select the link service then we can select the file. So the file which should be the dynamic so we can select as it is and file name will be blank first row as header so we can mark that and click on OK. So once we have set up this then this is the static so we need to get the file names as dynamic so we have to create a parameter here and let me call this parameter as file name go to the connection and under the file name now here we can select that parameter. So this file is coming as in dynamic so once we have make this change under the data set let me go into the pipeline level and now this data set is asking about the file name values from here so this file name value should be coming from this for each activity and the property which is the name property now let me click on OK. So now it will be having all these files one by one as the for each activity will be processed. Now here we can see the field list so let me try to click on this plus symbol and under the argument we can select the item name and the second argument we can select the last modified now once we have done this let me try to execute it. So we will see so for each activity is item is required. So here actually we have not set anything under these items so it will be going to process for the child items so we can select and now let me try to execute it. So it will be going to execute total five times and will be processing all these files and under the get metadata activity two we will see the file name along with the last modified. So we have to wait until this will not be executed so as we can see total five times get metadata activity two is executed and we can also check the item name and the last modified of that file. You need to remember like this is the format by which we are getting the last modified values now once we have done this now we need to check about your last modified date which is less than 20 days from today's date or not. So for checking that we have to use the if condition activity so we can drag and drop the if condition activity and connect with the get metadata activity two. Here we can see the activities and here the expressions so under the expression we need to write the expression. So I have already written the expressions let me try to copy and use it here and I will show you what this is doing. So first we are using the list so it is checking your last modified value that should be less than the second expression. So in the second expression what we are doing first we are using the UTC norm so it is returning for today's current date and time. Add days function will be adding the days on this. So here we are adding minus 20 so it is for less than the 20 days. So for example today is the 5th of September so minus 20 days will be the 16th of August. Now if you can go further so we are doing the format remember whatever the format we are getting under this get metadata activity to last modified so the same format I have already used over here. Now let me try to click on OK so once we have done this then under this true block once that condition will true then we want to delete those files. So let me try to use the delete activity here and under the delete activity we can go in the source and here we have to create a new data set. So let me click on new go to the Azure Blob Stories and after that here we can see the link service so we can select that in the file path we can browse and go to the folder which is the testing folder and after selecting the testing folder we can click on OK because the file name should be dynamic and this file name we will get from the get metadata activity to now once we have done this we can click on this open for making this data set as dynamic here the file name should be coming from the parameter. Let me try to add a new parameter value like delete file so this will be the file name and here we can use the same parameter which is the delete file. So once we have made this as dynamic then under the pipeline it is asking the value so this value are coming from the get metadata activity to as an item name so we can go here and we can see the item name we can select and click on OK. So once we have configured all these go to the locking and we do not want to keep the locking for this so everything looks OK now let me try to execute this pipeline. So once it will be executed then three files should be deleted into the Azure Blob Store under the testing folder so this execution is in progress so we have to wait so here we can see this is get metadata activity one is executed successfully and if you can go and try to audit from the bottom side then this should be going to return all those five files those are all able into the Blob Store in the for each activity it will be returning total five because total five files are there and under that we can see the get metadata activity two is executed five times so one for each time so like we can see the five files here so five times it is executed and processing one file at a time if condition will also be executed total five times as we can see but the delete activity should be executed only three times because as of now we can see five files but as per the condition for the less than 20 days so the five which is older than the 20 days is having total three files so that's why delete activity is executed three times let me try to refresh and we'll try to see so now it should be having only two files as we can see so other than that whatever the file which is older than the 20 days we have removed from this folder so the same condition is going to ask like your file will be 30 days or the 40 days or the 60 days so you can make the change on this expression only here we are adding minus 20 so you can add minus 30 minus 40 minus 50 minus 60 as per the interviews question so I hope guys you have clear understanding about this so thank you so much for watching this video see you in the next video with another interview question