我有一个基于 WebClient 调用的返回值创建 blob 的网络作业。这工作正常。但是从 Blob 属性中可以看出(见下面的代码),文件的名称是静态的。因此,它每次在 blob 存储中都会被覆盖。
函数类:
public class Functions
{
private static int _retryCount;
private static readonly int _retryLimit = int.Parse(ConfigurationManager.AppSettings["retryLimit"]);
private static readonly string _ghostRestfullUri = ConfigurationManager.AppSettings["ghostRestfullUri"];
[NoAutomaticTrigger]
public static void LightUpSite([Blob("ghost/response.json")] out string output, TextWriter logger)
{
_retryCount = 0;
output = string.Empty;
do
{
try
{
using (var request = new WebClient())
{
var response = request.DownloadString(_ghostRestfullUri);
_retryCount++;
output = response;
break;
}
}
catch(Exception exception)
{
logger.WriteLine("Job failed. Retry number:{0}", _retryCount);
}
} while (_retryCount < _retryLimit);
}
}
主菜单:
public class Program
{
static void Main()
{
var host = new JobHost();
host.Call(typeof(Functions).GetMethod("LightUpSite"));
}
}
如何使用占位符动态命名传入文件?
我已经尝试过以下方法:
- 幽灵/{name}
- 幽灵/{BlobName}
其他需要注意的事项:
此作业按计划运行,因此主机不会运行和阻塞此作业不会被触发器调用,它只是唤醒并运行;因为源不是来自消息队列对象或上传的文件,所以我无法弄清楚我应该如何命名这个 blob。
也许以某种方式直接使用 blob 存储 API?