在C中使用azure函数解压缩密码文件#

在C中使用azure函数解压缩密码文件#,azure,azure-functions,azure-web-app-service,azure-storage-blobs,Azure,Azure Functions,Azure Web App Service,Azure Storage Blobs,我正在尝试解压缩blob存储中受密码保护的文件。使用带有C#编码和winrar.exe的azure函数解压缩。。 我无法解压缩这些文件。。正在获取“未找到存档”警告 我像winrar.exe x-p{pwd}一样传递参数http://....//file.zip{输入BLOB文件uri}http://...//output//{输出blob容器uri} 请说明上述参数是否正确,或者是否需要更改以获取输入blob文件位置 霉菌代码: ProcessStartInfo sta

我正在尝试解压缩blob存储中受密码保护的文件。使用带有C#编码和winrar.exe的azure函数解压缩。。 我无法解压缩这些文件。。正在获取“未找到存档”警告

我像winrar.exe x-p{pwd}一样传递参数http://....//file.zip{输入BLOB文件uri}http://...//output//{输出blob容器uri}

请说明上述参数是否正确,或者是否需要更改以获取输入blob文件位置

霉菌代码:

            ProcessStartInfo startInfo = new ProcessStartInfo();
            startInfo.CreateNoWindow = false;
            startInfo.UseShellExecute = false;
            startInfo.WorkingDirectory = uri.AbsoluteUri;
            startInfo.FileName = "Winrar.exe";
            startInfo.WindowStyle = ProcessWindowStyle.Hidden;
            startInfo.RedirectStandardOutput = true;
            startInfo.RedirectStandardInput = true;
            startInfo.Arguments = "winrar.exe x -p" + pwd + " -ibck " + inputBlob.Uri.ToString()+ " " + outBlob.Container.Uri.ToString() + "/";
            try
           {
             // Start the process with the info we specified.
            // Call WaitForExit and then the using statement will close.
           using (Process exeProcess = Process.Start(startInfo))
           {
             exeProcess.WaitForExit();
            }
            }
           catch (Exception esf)
          {
             string msd = esf.Message;
          }

是否可以获得如下blob路径D:/home/site/。?

如果要通过Azure函数解压缩存储在Azure blob存储中的.zip文件,请尝试下面的代码snippy:

            var tempPath = "d:/home/temp/";
            var zipBlobName = "";
            var containerName = "";
            var password = "123456";
            var storageConnString = "";
            var tempFilePath = tempPath + zipBlobName;
            var zipDestPath = tempPath + "unzip";

            //download zip to local as a temp file
            var blobClient = new BlobServiceClient(storageConnString).GetBlobContainerClient(containerName).GetBlobClient(zipBlobName);
            blobClient.DownloadTo(tempFilePath);

            //unzip file to a folder 
            ZipFile zip = ZipFile.Read(tempFilePath);
            zip.Password = password;
            Directory.CreateDirectory(zipDestPath);
            foreach (ZipEntry e in zip)
            {
               e.Extract(zipDestPath, ExtractExistingFileAction.OverwriteSilently);
            }
            zip.Dispose();

            //remove temp zip file
            File.Delete(tempFilePath);
在这个演示中,我使用的是
Ionic.Zip
。 我已经在我这边进行了测试,它对我非常有效:

如果你还有任何问题,请告诉我

更新:

在Azure函数中创建临时路径:


谢谢您的回复。我对给定的临时路径有疑问。临时路径在门户上是否保持不变?在这种情况下,如何删除这些文件。@Sree,您需要通过命令在Azure函数上创建路径:
mkdir
由kudu编写,我已在回答中附加了捕获。您可以通过code
File.Delete(tempFilePath)删除文件:我的代码的最后一行将此解决方案适用于大约30gb的较大文件大小。它们会影响性能吗?也可以在Azure函数中运行.exe文件吗?@Sree,如果您的文件大小超过30GB,恐怕您需要分块下载.zip文件,详细信息请参阅此文档:,可以在Azure函数中运行.exe文件。如果您想这样做,此帖子可能会有所帮助:@Sree进展如何?你的问题解决了吗?