如果映像存在,请检查Azure CDN
本文关键字:检查 Azure CDN 映像 存在 如果 | 更新日期: 2024-09-25 08:08:13
是否有任何方法,使用任何.Net Azure库来检查CDN上是否存在资源。我可以检查blob是否存在,但没有发现任何可以检查它是否也存在于CDN 上的内容
假设您的BLOB URL是:
http://foo.blob.core.windows.net/cdn/test.png
并且您的CDN端点是bar.vo.msecnd.net
只需在http://bar.vo.msecnd.net/cdn/test.png
上执行HTTP HEAD请求,即可查看该文件是否存在。
转述本答案中提交的代码
HttpWebResponse response = null;
var request = (HttpWebRequest)WebRequest.Create("http://bar.vo.msecnd.net/cdn/test.png");
request.Method = "HEAD";
try
{
response = (HttpWebResponse)request.GetResponse();
}
catch (WebException ex)
{
/* do something here */
}
finally
{
// Don't forget to close your response.
if (response != null)
{
response.Close()
}
}