简体   繁体   English

如何使用 Azure Function 从网站下载文件

[英]How to download files from a website with Azure Function

I'm not very familiar with Azure functions but am trying to learn and explore how to download files from a website using a time triggered function.我对 Azure 函数不是很熟悉,但我正在尝试学习和探索如何使用时间触发的 function 从网站下载文件。 I have the following code:我有以下代码:

namespace PracticeFunction
{
    public static class PracticeFunction 
    {
        [FunctionName("Function1")]
        public static void Run([TimerTrigger("0 */5 * * * *")]TimerInfo myTimer, ILogger log)
        {
            log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

            using (var client = new WebClient())
            {
                client.DownloadFile("https://examplewebsite.com/file.zip", "zipfile");
            }
        }
    }
}

The function executes 'successfully' but the file doesn't seem to have downloaded anywhere. function 执行“成功”,但文件似乎没有下载到任何地方。 I am sure I am missing something very obvious but could anyone please point me in the right direction?我确定我遗漏了一些非常明显的东西,但有人能指出我正确的方向吗?

client.DownloadFile("https://examplewebsite.com/file.zip", "zipfile");

The file is downloaded in a file named zipfile in your executable's folder, which is probably in your solution folder, in bin and then a couple more folders deep depending on your build configuration.该文件将下载到可执行文件文件夹中名为zipfile的文件中,该文件可能位于您的解决方案文件夹中,在bin中,然后根据您的构建配置,再深入几个文件夹。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM