Issue while deletion of item using script on Azure - azure

Environment: Azure PAAS
Activity: Deletion of folders, sub-folders and yml files
As part of our CI-CD process, we delete a folder, sub-folders and yml files. We do this activity in 2 different regions.
The deletion has failed for a set of items in Staging and another set in Production. Surprisingly that has happened only in a particular region (EU-West). The remaining objects have got deleted by the same script successfully.
The error logged is for the Unauthorized access exception.
We have been able to delete the folder, including its content from the Azure command prompt.
As the folder is inside D:, we could not try it from the UI.
Please advice.

Related

Trying to copy folder from release pipeline to Azure BLOB ended up with no content copied but task is successfully completed

Try to copy JMeter report to AZ BLOB container.
Using Ubunto agent in release pipeline ,as the Azure blob file copy only supported from Win agent i've tried to find some other way to do the copy on a linux agent.
Running the following command in Azure CLI task:
azcopy copy '$(System.DefaultWorkingDirectory)/Report' 'https://account.blob.core.windows.net/container?sp=racwdl&st=2021-04-22T12:12:49Z&se=2022-06-01T20:12:49Z&spr=https&sv=2020-02-10&sr=c&sig=xxxx' --recursive=true
I want to copy all the content of folder 'Report' to the AZ BLOB recursively.
The task is finished successfully but no files at all were copied.
Using SAS for the container.
Attached the task logs of running.
Any ideas?
Make sure you did not put the files into a wrong path for Reports folder. You can check your variable for $(System.DefaultWorkingDirectory) variable under Pipeline or print it out under pipeline.
With all the steps, you should make sure the files are in the right directory.
Besides, you could use the variable system.debug: true to check the detailed log about your task.

Read Resource File in application which has been uploaded to Azure Batch

I am using Azure batch Service and I am able to add applications,pools and tasks to the same .I have attached a resource file to each task.I am confused about how to access the resource file or inputs provided to the task in the application that I have uploaded to the Azure batch .Please help me in the same
If you have attached the ResourceFile(s) to the individual tasks then the file(s) should be uploaded to the filePath you specified(if any) appended to the environment variable in your task of AZ_BATCH_TASK_WORKING_DIR (https://learn.microsoft.com/en-us/azure/batch/batch-compute-node-environment-variables).
For an ad-hoc experience you can download https://azure.github.io/BatchExplorer/ and navigate to an existing node and/or task to see a file explorer for how the directories in the node are layed out.

How to create a empty folder in Azure Blob from Azure databricks

I have scenario where I want to list all the folders inside a directory in Azure Blob. If no folders present create a new folder with certain name.
I am trying to list the folders using dbutils.fs.ls(path).
But the problem with the above command is it fails if the path doesn't exist, which is a valid scenario for me.
If my program runs for the first time the path will not exist and dbutils.fs.ls command will fail.
Is there any way I can handle this scenario dynamically from Databricks.
It will also work for me if I can create an empty folder in Azure Blob from Databricks before executing my job.
I have tried running below command from databricks notebook
%sh mkdir -p /mnt/<mountName>/path/folderName
Here the command runs successfully and even though my container in Azure Blob is mounted it doesn't create the folder.
Sorry for such an elongated post. Any help is much appreciated. Thanks in advance
dbutils.fs.mkdirs("/mnt/<mountName>/path/folderName")
I found this was able to create a folder with a mounted blob storage

Find Azure slot location in azure App Service Deploy

How to find Destination path of deployed web site on Azure App Service Deploy - Azure Slot ?
I need to delete existing old files on a destination specific folder which are generated uniquely on each release(during build process).
This has to be done during pre-deployment.
I used Delete Files Task which is not deleting. Here is YAML.
In Kudu , I am able to see my web site location is D:\home\site\wwwroot\
I wanted to delete files from the path D:\home\site\wwwroot\scripts\libs>
steps:
task: DeleteFiles#1
displayName: 'Delete files from $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(build.artifactstagingdirectory)'
Contents: 'scripts\libs**'
You don't have to manually delete old files on your App Service Instance or its Deployment Slots. When you are using Azure App Service Deploy task you have the option built-in to remove any unused files at the destination (in this case App Service Instance/Deployment slot). Here is how to do it.
On the Azure App Service Deploy task,
Expand Additional Deployment Options.
There make sure Select Deployment Method checkbox is selected
From the Deployment Method drop down, Select Web Deploy
Select the Remove additional files at destination checkbox
If you want to keep any file that is installed with App Service Extensions or WebJobs select Exclude files from the App_Data folder as well
What this will do is it will compare the files that are already at the destination (App Service) with the files that will be copied over from the Artifacts. Then it will delete any file that is not available in the artifacts that you are doing to deploy.
Find Azure slot location in azure App Service Deploy
You may not delete the correct folder.
According to the first image in your question, we could to know you are deleting the file from the folder $(build.artifactstagingdirectory).
As we know, the folder $(build.artifactstagingdirectory) is the local path on the agent where any artifacts are copied to before being pushed to their destination.
Check Build variables for some more details.
However, I do not find any task in your build definition to copy file to the artifacts.
Besides, you said you delete existing old files on a destination specific folder which are generated uniquely on during build process.
So, I am bold to guess that the file you want to delete should be in System.DefaultWorkingDirectory instead of artifacts. But I am not very sure about it, since I could not distinguish folder type from the path D:\home\site\wwwroot\scripts\libs>.
So, to resolve this issue, you can try to delete the file from $(System.DefaultWorkingDirectory).
Or you can use a Inline Powershell task to outcome the value of $(build.artifactstagingdirectory):
Write-Output '$(Build.ArtifactStagingDirectory)'
Then check if the value is match the path of folder you want to delete D:\home\site\wwwroot\scripts\libs>.
Hope this helps.

Application fails to start when using Azure website package deployment

We've recently switched to using Azure package deployment for our sites (https://github.com/Azure/app-service-announcements/issues/84) - and it's great! It's a great feature which has radically simplified our deployments. However we have a second site which will not run when packaged (but does run when not packaged).
We followed the standard procedure for setting a site to run from a package;
created the folder /data/SitePackages from ftp,
drop the package in there along with the packagename.txt file
set the App config setting WEBSITE_RUN_FROM_PACKAGE=1
However we receive "You do not have permission to view this directory or page." on the homepage, and any other subsequent page we receive "The resource you are looking for has been removed, had its name changed, or is temporarily unavailable.". It's as though the site isn't loading the package at all? Azure Log stream show's "HTTP Error 401.3 - Unauthorized" on the home page and a standard 404 for anything else.
From the Azure portal, if i click console and ls to see a directory listing of the files it thinks it's running all I see is a single file;
FAILED TO DOWNLOAD ZIP FILE.txt
Turns out this was the azure portal not loading the package. Looking at our TeamCity setup, the step which generates the "packagename.txt" file has a typo, so the zip file Azure was trying to load did not exist.

Resources