是否可以访问浏览器、网站点击日期和时间、IP 地址等分析?
从此处的文档来看,Azure App Insights 似乎仅适用于使用 Azure Functions 的静态 Web 应用程序。我只有一个静态网站,没有 API。
理想情况下,我想设置Diagnostic Setting并使用 Azure Log Analytics 来查看分析。
如何在没有函数 API 的情况下对静态 Web 应用程序进行更深入的分析?
编辑1:我想至少捕获某处的点击次数。
analytics azure azure-application-insights azure-static-website-hosting azure-static-web-app
我正在尝试新的 Azure 静态网站托管预览版,在本地运行时,Azure 函数未接收 req 绑定对象中的“x-ms-client-principle”标头。
我的路线文件如下所示:
{
"routes": [
{
"route": "/api/*",
"allowedRoles": ["administrator"]
},
{
"route": "/*",
"serve": "/index.html",
"statusCode": 200
}
]
}
Run Code Online (Sandbox Code Playgroud)
我的 API 函数在: 处受到攻击/api/message,但不包括标头。
module.exports = async function (context, req) {
const header = req.headers["x-ms-client-principal"]; // req.headers doesn't include x-ms-client-principle
const encoded = Buffer.from(header, "base64");
const decoded = encoded.toString("ascii");
}
Run Code Online (Sandbox Code Playgroud)
静态应用程序是使用 create-react-app 创建的 React 静态页面。我有一行可以打印出反应应用程序的结果:
fetch(`${process.env.REACT_APP_API}/message?name=me`)
.then(a => a.text())
.then(console.log);
Run Code Online (Sandbox Code Playgroud)
本地process.env.REACT_APP_API通过 进行设置REACT_APP_API=http://127.0.0.1:7071/api。
API 受到攻击,但我不确定它是否运行正确版本的 Azure Functions。它报告:Function Runtime …
我们使用 Azure Front Door 为我们的白标静态网站提供服务,这意味着我们需要我们的客户能够通过独特的子域(例如cust1.domain.com和cust2.domain.com)访问它。
我们*.domain.com通过 DNS 对 Front Door 实例进行 CNAME,映射路由*.domain.com并将其绑定到自定义*.domain.com通配符证书(未托管,不受支持)。该路由指向一个源组,该组又指向类似于 的“存储(静态网站)”源prod-storage.z14.web.core.windows.net。
有时在 Safari 上,我们会收到如下所示的响应:
<h2>Our services aren't available right now</h2><p>We're working to restore all services as soon as possible. Please check back soon.</p>0a1LIYwAAAADIYjiE3LgzTLfw86bqHEd5Q0hHRURHRTE2MTAAYTk0OGVmNjEtMTk3NS00ZjA0LTkwMjgtOTgwY2I4YzllYzFl
Run Code Online (Sandbox Code Playgroud)
在查看网络选项卡时,我们看到响应实际上是一个421 Misdirected Request. 我的假设是它与此更新有关: https: //learn.microsoft.com/en-us/azure/frontdoor/front-door-faq#how-does-front-door-handle--domain-fronting - 行为 -
设置此流程以避免 Front Door 出现此新问题的正确方法是什么?据我所知,我们的案例有些独特,并且没有记录。
我见过的解决方案包括关闭 HTTP/2、为每个域创建单独的证书以及使用不同的 IP - 这些解决方案都无效,也不会随我们的解决方案扩展,因为我们需要不受限制地动态创建新的子域(即,以编程方式将它们添加到 AFD 是不现实的)。
wildcard-subdomain azure http-status-code-421 azure-front-door azure-static-website-hosting
当我在 Chrome 中本地加载 HTML 时,该文本如下所示:
相反,这是我发布到 Azure 静态网站后呈现的样子:
撇号、引号和其他字符被呈现为一些奇怪的文本。
这是什么原因?为什么只有在发布时才会发生?对我来说似乎是一个 Azure 错误。