function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Pankaj PahadePankaj Pahade 

How to delete file from Azure Storage using Apex or LWC?

How to delete file from AzureStorage using Apex or LWC?
PriyaPriya (Salesforce Developers) 
Hey Pankaj,

You need to provide more detail about your requirement.

Thanks!
Pankaj PahadePankaj Pahade
Hello Priya,

I have two ways in my mind,
1. using Http call from Apex
2. Calling AzureStorage or CloudBlobClient directly in LWC (But I am not able to import AzureStorage inside LWC to utilized Azure standard methods )

Currently I am doing,

            HttpRequest req = new HttpRequest();
            req.setTimeout(120000);
            req.setMethod('DELETE');

            req.setHeader('x-ms-blob-type', 'BlockBlob');
            req.setHeader('x-ms-date',System.Now().formatGMT('EEE, dd MMM yyyy HH:mm:ss z'));
            req.setHeader('x-ms-version', '2015-12-11');
            
            req.setEndpoint('https://'+StorageName+'.blob.core.windows.net/'+Container+'/'+image (1).png+'?'+SASToken);
            Http http = new Http();

            try {
                HTTPResponse res = http.send(req);
                
                if(res.getStatusCode() == 201){
                   System.debug('res.getStatusCode()--------> '+res.getBody());
                }else{
                    System.debug('Not Deleted--------> ');
                   System.debug('res.getStatusCode() in else--------> '+res.getBody());
                   System.debug('res.toString()--------> '+res.toString());
                }
                
            } catch (system.CalloutException ce){
                system.debug(ce);
            }

But, I am getting 'HTTP Error 400. The request is badly formed.' as result, if more information needed let comment on same,
please give me some idea or some related reference on this part 
dhiraj koparkar 10dhiraj koparkar 10
Hii Pankaj did you solve this problem i also have requirment to delete file from azure
Can you or anyone help me to solve my requirment