如何正确将Azure CDN终结点映射到Blob存储容器中的Angular 7 Project

时间:2019-04-24 06:41:11

标签: azure azure-storage-blobs azure-cdn

我一直在尝试创建Azure CDN终结点以为Angular 7项目创建Blob存储容器。

遵循以下步骤。

  1. 设置了标准的HOT LRS Blob存储。
  2. 在创建的blob下,创建了一个可以访问blob匿名读取访问权限的容器。
  3. 将dist / *上载到容器。

  4. 使用标准Verizon创建的CDN配置文件

  5. 创建了一个端点,其原始主机名设置为上方的点1,并且指向blob容器的原始路径。

现在,我的端点主机名看起来是https://<myendpoint>.azureedge.net

当我从浏览器导航到此链接时,没有默认的XML显示。 当我导航到https://<myendpoint>.azureedge.net/<blobcontainer>/index.html时,显示索引页面,但以net::ERR_ABORTED 404

结尾

它尝试从路径styles.hash.css, runtime.hash.js而不是路径https://<myendpoint>.azureedge.net/下载支持文件,例如https://<myendpoint>.azureedge.net/<blobcontainer>/等,因为这些文件不存在,所以出现此错误。

如何正确将Azure CDN终结点映射到Blob存储容器中的Angular 7 Project?

我尝试了什么?

  1. 我将orginpath移到了端点
  2. Blob容器访问Blob和容器的匿名用户
  3. 我做了purgeall

更新:Azure VM的IIS中端口XX和E:\ XX中的虚拟目录中的虚拟机正在工作

这是我的由cli生成的dist / index.html。

<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>Angular</title>
  <base href="/">

  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="icon" type="image/x-icon" href="favicon.ico">

<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf/1.5.3/jspdf.min.js"> </script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/2.3.5/jspdf.plugin.autotable.min.js"></script>
<!-- Other CDN content -->

<link rel="stylesheet" href="styles.d53c073df9bdc9d8dc56.css"></head>
<body>
  <app-root> </app-root>
<script type="text/javascript" src="runtime.e34dbbfe0677512b179e.js"></script>
<script type="text/javascript" src="polyfills.24a4835bc4e54cff0563.js">
</script><script type="text/javascript" src="main.3d2c3408bf112b226574.js"></script>
</body>
</html>

也有许多博客建议在blob存储帐户上切换静态网站,但我在Azure门户->存储帐户-> Blob或Blob->容器中找不到这种选项。

1 个答案:

答案 0 :(得分:0)

请缩小注释范围,以回答该问题,以获取更多参考。

Azure Storage 通用v2帐户允许您直接从名为$web的存储容器中提供静态内容(HTML,CSS,JavaScript和图像文件)。 您可以在Azure门户中的Settings--->Configuration--->upgrade之后将当前的存储帐户升级到V2,然后在“存储帐户的设置”中看到Static website选项。

接下来,通过Azure门户将资产上传到$web容器。

要为此静态网站配置CDN端点(除了存储选项之外),您还可以选择自定义来源作为origin type。如果是这样,您可以在静态网站中将诸如storageaccount.z19.web.core.windows.net之类的主要端点主机名作为origin hostname

有关更多参考:Static website hosting in Azure Storage

相关问题