azure设置静态ip_如何在Azure上托管Vue JS静态网站

news/2024/5/10 20:39:44/文章来源:https://blog.csdn.net/weixin_26724171/article/details/109071046

azure设置静态ip

There are a number of ways you can build a website with Vue.js such as Java with Vue, NodeJS with Vue, NGINX serving Vue, etc. For the single-page applications, all you need to do is to load the initial index.html. Once you load the index.html the Vue library kicks in and do the rest of the job like loading components, calling API calls, etc. What if there are no backend calls and you want to build a static website with Vue.js?

您可以通过多种方式使用Vue.js构建网站,例如Java与Vue,NodeJS与Vue,NGINX服务Vue等。对于单页应用程序,您要做的就是加载初始索引。 html。 加载index.html之后,Vue库就会启动,并完成其余工作,如加载组件,调用API调用等。如果没有后端调用,并且您想使用Vue.js构建静态网站怎么办?

Azure CDN with blob storage is one of the options which provides a low cost and highly reliable static website hosting solution. These static sites have only CCS, HTML, JS files, fonts, etc. In this post, we can see how we can build a static website with Vue and host that on Azure.

具有blob存储的Azure CDN是提供低成本和高度可靠的静态网站托管解决方案的选项之一。 这些静态网站只有CCS,HTML,JS文件,字体等。在本文中,我们可以看到如何使用Vue构建静态网站并将其托管在Azure上。

  • Example Project

    示例项目

  • Prerequisites

    先决条件

  • Host Static Website With Azure Blob Storage

    使用Azure Blob存储托管静态网站

  • Deliver With Azure CDN

    随Azure CDN一起交付

  • Uploading With Azure CLI

    使用Azure CLI上传

  • Summary

    概要

  • Conclusion

    结论

示例项目(Example Project)

Here is an example project which we can put in the Azure blob storage for static website hosting. This is a simple profile page with a header and some sections.

这是一个示例项目,我们可以将其放入Azure Blob存储中以进行静态网站托管。 这是一个简单的配置文件页面,其中包含标题和一些部分。

// clone the project
git clone https://github.com/bbachi/my-profile-vuejs.git// install dependencies and start the project
npm install
npm run serve
Image for post
Example Project 示例项目

先决条件(Prerequisites)

You should be familiar with Vue and how Vue CLI Service builds stuff. If you are not familiar with Vue check out this link or go to their official website here.

您应该熟悉Vue以及Vue CLI服务如何构建东西。 如果您不熟悉Vue,请查看此链接或在此处访问其官方网站。

  • Vue

    Vue

  • Install Vue CLI Service

    安装Vue CLI服务

  • Sample Project Github link

    示例项目Github链接

Once you install the necessary components and run the above project on your local machine. It’s time to create Microsoft Azure Account checkout this link

安装必要的组件并在本地计算机上运行以上项目后。 是时候创建Microsoft Azure帐户签出此链接了

  • Microsoft Azure Account

    Microsoft Azure帐户

  • Create a subscription

    创建订阅
  • Create a Storage Account

    创建一个存储帐户

You can see the below dashboard once you create your account.

创建帐户后,您可以看到以下信息中心。

Image for post
Azure Dashboard Azure仪表板

创建订阅(Create a subscription)

You need to create a subscription that’s how It serves as a single billing unit for Azure resources in that services used in Azure are billed to a subscription

您需要创建是如何它作为Azure的资源的单一计费单位,在Azure中使用的服务被宣传为订阅订阅

Image for post
Pay-As-You-Go Subscription 随用随付订阅

创建一个存储帐户(Create a Storage Account)

An Azure storage account contains all of your Azure Storage data objects: blobs, files, queues, tables, and disks. The storage account provides a unique namespace for your Azure Storage data that is accessible from anywhere in the world over HTTP or HTTPS. Let’s create a storage account under this subscription.

一个Azure存储帐户包含您所有的Azure存储数据对象:blob,文件,队列,表和磁盘。 该存储帐户为您的Azure存储数据提供了唯一的命名空间,可通过HTTP或HTTPS从世界上的任何地方访问该存储空间。 让我们在此订阅下创建一个存储帐户。

Image for post
Storage Account 储存帐号

If you don’t have resource groups under subscription you need to create one. Resource groups are the ones that groups all your resources under the subscription. You can create multiple resource groups.

如果订阅中没有资源组,则需要创建一个。 资源组是将预订下的所有资源分组的组。 您可以创建多个资源组。

Image for post
Create a Storage Account 创建一个存储帐户

Once you review and create you can see the following screens.

审核和创建后,您将看到以下屏幕。

Image for post
deployment is underway 部署正在进行中
Image for post
deployment complete 部署完成

使用Azure Blob存储托管静态网站(Host Static Website With Azure Blob Storage)

Now we have a subscription, resource groups, and storage accounts created on our Azure account. It’s time to build our app with this command npm run build. When you do that all the built assets can be found in the dist folder.

现在,我们在Azure帐户上创建了一个订阅,资源组和存储帐户。 现在是时候使用此命令npm run build.来构建我们的应用程序了npm run build. 执行此操作后,可以在dist文件夹中找到所有构建的资产。

Image for post
npm run build npm运行构建

Now, go to your storage account on Azure and click on the static website on the left navigation and give the required index and error pages.

现在,转到您在Azure上的存储帐户,然后单击左侧导航栏中的静态网站,并提供所需的索引和错误页面。

Image for post
static website 静态网站

Once you enabled Azure creates we container called $web in which you can upload all your build files as below and it creates the primary endpoint as well.

启用后,Azure会创建一个名为$ web的容器,您可以在其中上载所有构建文件,如下所示,它还会创建主要端点

Image for post
upload all your build files 上传所有构建文件

Copy the primary endpoint and hit it in the browser once the upload is complete.

复制主要端点,并在上传完成后在浏览器中将其命中。

Image for post
Copy the endpoint 复制端点
Image for post
static website 静态网站

If you want to create a folder and upload it into that folder you can do that by selecting advanced and name the folder. I named it my-profile here.

如果要创建一个文件夹并将其上传到该文件夹​​,可以通过选择高级并命名该文件夹来完成。 我在这里将其命名为我的个人资料。

Image for post
Upload to a folder 上载到资料夹

In this case, you have to change the context path on the Vue app as well to my-profile

在这种情况下,您必须将Vue应用程序上的上下文路径也更改为“我的个人资料”

随Azure CDN一起交付 (Deliver With Azure CDN)

You can enable Azure Content Delivery Network (CDN) to cache content from a static website that is hosted in an Azure storage account that provides consistent low latencies to your website from anywhere in the world.

您可以启用Azure内容交付网络(CDN)来缓存来自Azure网站中托管的静态网站的内容,该静态网站可以在世界各地为您的网站提供一致的低延迟。

Let’s select an Azure CDN under blob service and give CDN endpoint name and you need to select your Azure blob storage URL as the origin hostname. Make sure you remove protocol identifier https and trailing slash at the end.

让我们在blob服务下选择一个Azure CDN并指定CDN终结点名称,然后需要选择Azure blob存储URL作为原始主机名。 确保删除协议标识符https和末尾的斜杠。

Image for post
Creating an Azure CDN 创建一个Azure CDN

If it’s successful you can see newly created endpoints under the Endpoints section.

如果成功,您可以在“端点”部分下看到新创建的端点。

Image for post
Endpoints 终点

You can see all the details about this endpoint when you click on it such as the resource group, location, subscription, endpoint, origin, etc.

单击此端点后,您可以查看有关该端点的所有详细信息,例如资源组,位置,订阅,端点,来源等。

Image for post
Endpoint Details 端点详细信息

After creating a CDN endpoint, it will not immediately be available for use, as it takes time for the registration to propagate through the CDN. You might get this following error page.

创建CDN终结点之后,它将无法立即使用,因为注册需要花费一些时间才能通过CDN传播。 您可能会收到以下错误页面。

Image for post
404 Page 404页

Make sure you go through this troubleshooting page. If you set up everything correct wait for 10 minutes or so, it will start working.

确保您通过此故障排除页面。 如果一切正确,请等待10分钟左右,它将开始工作。

Image for post
Distribute With Azure CDN 使用Azure CDN分发

使用Azure CLI上传(Uploading With Azure CLI)

We have done everything manually. We can actually do the same thing with Azure CLI commands Let’s see how we can do that.

我们已手动完成所有操作。 实际上,我们可以使用Azure CLI命令执行相同的操作。让我们看看如何做到这一点。

Step1: The first step would be logging in with Azure CLI. This configures the CLI with the user account. It will open the browser and takes your credentials and gives you a JSON response.

步骤1:第一步是使用Azure CLI登录。 这将使用用户帐户配置CLI。 它将打开浏览器并获取您的凭据,并为您提供JSON响应。

az login

Step2: Let’s create a subscription or set the subscription that you are using for the next commands.

步骤2:让我们创建一个订阅或设置您要用于下一个命令的订阅。

// list subscriptions
az account list --output table// ses the subscription
az account set --subscription bc5fbeca-2e67-4bfb-85bb-58480ab3bb30

Step3: Create a resource group

第三步:创建资源组

az group create --name staticwebhosting --location westcentralus

Step4: Let’s create a storage account with resource group name staticwebhosting and location eastus

步骤4:让我们创建一个资源组名称为staticwebhosting和位置eastus的存储帐户

az storage account create \
--name staticvueweb \
--resource-group staticwebhosting \
--location eastus \
--sku Standard_ZRS \
--encryption-services blob

Step5: Enable static web hosting on that storage account

步骤5:在该存储帐户上启用静态网络托管

az storage blob service-properties update \
--account-name staticvueweb \
--static-website \
--404-document error.html \
--index-document index.html

Step6: Upload all the documents to the blob storage

步骤6:将所有文件上传到Blob储存空间

az storage blob upload-batch -s ./dist/ -d \$web \
--account-name staticvueweb

Step7: Create a CDN endpoint with the following command

步骤7:使用以下命令创建CDN端点

az cdn endpoint create -g staticwebhosting \
-n endpointName \
--profile-name profileName \
--origin <endpoint of your blob service>

概要 (Summary)

  • Azure CDN with blob storage is one of the options which provides a low cost and highly reliable static website hosting solution.

    具有blob存储的Azure CDN是提供低成本和高度可靠的静态网站托管解决方案的选项之一。
  • You need to create an Azure account, subscription, resource groups, and storage account before you create static website hosting.

    在创建静态网站托管之前,您需要创建一个Azure帐户,订阅,资源组和存储帐户。
  • You need to create a subscription that’s how It serves as a single billing unit for Azure resources.

    您需要创建一个订阅,以此作为Azure资源的单个计费单位。

  • An Azure storage account contains all of your Azure Storage data objects: blobs, files, queues, tables, and disks.

    一个Azure存储帐户包含您所有的Azure存储数据对象:blob,文件,队列,表和磁盘。
  • Resource groups are the ones that groups all your resources under the subscription.

    资源组是将预订下的所有资源分组的组。
  • You can just upload all the built files to the $web container that the storage account created for you when you enable a static website.

    您可以将所有构建的文件上载到启用静态网站时存储帐户为您创建的$ web容器中。
  • You can upload all the files into a folder as well. In that case, you have to build the app with that particular context path.

    您也可以将所有文件上传到文件夹中。 在这种情况下,您必须使用特定的上下文路径来构建应用程序。
  • You can set up an Azure CDN endpoint for your static website on the Azure blob storage.

    您可以在Azure blob存储上为静态网站设置Azure CDN终结点。
  • After creating a CDN endpoint, it will not immediately be available for use, as it takes time for the registration to propagate through the CDN.

    创建CDN终结点之后,它将无法立即使用,因为注册需要花费一些时间才能通过CDN传播。
  • Here is the troubleshooting page if something goes wrong.

    如果出现问题,这是故障排除页面。

  • You can map to a custom domain as well if you have one.

    您也可以映射到自定义域。

结论 (Conclusion)

Static website hosting on the Azure is pretty straight forward. Try this if you are building static web apps.

在Azure上托管静态网站非常简单。 如果要构建静态Web应用程序,请尝试此操作。

翻译自: https://medium.com/bb-tutorials-and-thoughts/how-to-host-a-vue-js-static-website-on-azure-81ef1f4c79f3

azure设置静态ip

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.luyixian.cn/news_show_905395.aspx

如若内容造成侵权/违法违规/事实不符,请联系dt猫网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

java简单实现xml网站地图

本来用某鱼抓取整理网站url的&#xff0c;结果超过一万条要付费充会员导出&#xff0c;有点郁闷&#xff0c;怎么办&#xff1f;因为java爬虫还不怎么会&#xff0c;就只有拼接了&#xff0c;想想就是查库然后转换成xml&#xff0c;勤快点自己动手。 获取网站url的后缀地址&…

引路蜂Android技术网站开通了

之前在引路蜂技术博客我们花了大量的篇幅介绍了Android开发的相关知识&#xff0c;距离上次介绍Android开发已经有一年有余&#xff0c;这期间Android版本也有了很大的变化&#xff0c;好在Android的版本的基本支持向下兼容&#xff0c;因此以前的介绍的技术基本上还是适用的&a…

开启智慧的10大网站--非常值得收藏!

NO1,大学资源网&#xff1a; http://www.dxzy163.com/ 优点&#xff1a;课程非常多&#xff0c;里面课程质量非常高&#xff0c;并且不注册、不收费&#xff0c;实在太棒了&#xff0c;一直使用当中&#xff01; 缺点&#xff1a;有个别课程无法播放。 大学资源网致力于为每…

一例千万级pv高性能高并发网站架构

受CU管理员的邀请参考“千万级pv高性能高并发网站架构与设计交流探讨帖”主题的交流&#xff0c;发表了一案例与大家分享。 一个支撑千万级PV的网站是非常考验一个架构是否成熟、健壮(本文不涉及软件架构的层面&#xff0c;有兴趣也可以讨论)。现抛出一个系统层面的架构&…

《网站被黑》

目录 一&#xff0c;补充知识 1&#xff0c;黑客攻击的步骤与防范 &#xff08;1&#xff09;网络本身存在的安全缺陷 &#xff08;2&#xff09;黑客攻击的步骤 &#xff08;3&#xff09;黑客攻击的方法 &#xff08;4&#xff09;黑客攻击的防范&#xff08;被攻击前怎…

大型网站系统架构演化之路

前言 一、最开始的网站架构 二、应用、数据、文件分离 三、利用缓存改善网站性能 四、使用集群改善应用服务器性能 五、数据库读写分离和分库分表 六、使用CDN和反向代理提高网站性能 七、使用分布式文件系统 八、使用NoSql和搜索引擎 九、将应用服务器进行业务拆分 十、搭建分…

Google分析中阻止垃圾SEO流量6种方法

当您担心假流量时,谁会关心假新闻?几年前,垃圾邮件是您电子邮件收件箱中的垃圾邮件。不久之后,电子邮件提供商创建了阻止垃圾邮件进入您的收件箱的过滤器,似乎您不必再担心它了。快乐的时光!但是,既然您已经拥有了一个网站,则垃圾邮件已重新成为您的雷,它正在追随您的…

今年应避免的网站营销错误

如果您希望您的企业拥有成功的互联网存在,会与您分享您在2019年应避免的7个营销错误。 如果没有网站,您就无法在当前的氛围中开展业务,并且您最需要该页面将访客转化为客户。以下七个提示可以帮助您使您的网站远离失败的境界。 您是否发现自己的网站流量充足,但客户却不是…

留意这5个黑帽SEO的迹象

黑帽SEO指的是帮助网站在谷歌排名更高的不道德行为。很多时候,一个网站甚至不知道它遭受黑帽搜索引擎优化 - 并因此而受到惩罚。 虽然黑帽可以暂时帮助谷歌的网站排名更高,搜索引擎最终会因为不良做法而降级。你需要知道如何识别黑帽SEO技术。以下是您网站和其他网站需要查看…

SEO的最佳URL结构是什么?

您的许多访问者都会通过点击链接访问您的网站,因此您可能想知道特定网页的实际网址中的内容是否真实重要。 您可能会惊讶地发现,当谈到现场搜索引擎优化时,您的网址看起来真的非常重要。 一、什么是URL结构? 您的网站URL作为您在网络上的地址。这是有人访问您网站页面的最…

通过关键词广告提高网站曝光和信任度

关键字广告和搜寻引擎优化 (SEO) 之间互相影响,协作使用时,可以达到更好的效果。 品牌曝光和信任 由于法例所限需要注明该片段为广告内容。一般人都知道广告是以钱换取曝光,对广告内容的信任程度会打折。但从心理学研究知道存在单纯曝光效应 Mere Exposure Effect,就是说…

关键词后计划时代的SEO成功4个技巧

如果您还没有收到或没有注意到,Google现在会限制关键字规划中的搜索量,以便为“每月支出较低”付费搜索的用户提供搜索量。这意味着,如果您没有在付费搜索上花费足够,那么“免费”工具对于确定有多少人搜索特定关键字实际上毫无用处。 对于许多使用该工具进行研究但没有资金…

SEO:HTML,XML网站地图介绍

站点地图有两种类型:HTML和XML。HTML网站地图主要是用来指导访问者的。XML网站地图可指导搜索引擎机器人,确保他们找到要索引的网站URL 。了解它们各自的优缺点将有助于您的搜索引擎优化。 XML网站地图 XML使信息机器可读。XML网站地图为搜索引擎提供了网站上URL的有效列表。…

您选择的虚拟主机类型会影响您的SEO?

标题 一、您的虚拟主机计划可以影响SEO吗&#xff1f; 谈到SEO&#xff0c;细节很重要。其中一个通常被忽视的细节是您选择的网络主机。通常&#xff0c;这是人们想到的最后一件事。 但是&#xff0c;您使用的托管类型会对您的排名产生重大影响。影响的程度取决于您网站的规模…

简单的小说阅读网站JavaWeb项目

暂时介绍一下这个项目目前有哪些功能 这是项目的主页 这是登录界面 这是注册页面 使用普通用户登录后 这是书酷界面 这是排行界面 这是书架界面 这是个人信息界面 这是书籍详情页 使用管理员登录后的用户信息界面 这是小说阅读页面 这是目录 这是一个音乐小插件&…

【实践】python 提取网站里面的汉字

提取网站里面的汉字 1、引入模块 requests&#xff08;用于获取网站上的数据&#xff09;&#xff1b;json&#xff08;用于解析json数据&#xff09; # codingutf-8 import requests as r import json2、写入到txt a作为追加&#xff0c;不清空之前的数据 txt open("…

Struts,MVC 的一种开放源码实现用这种servlet和JSP框架管理复杂的大型网站

(转载自IBM developerWorks中国网站 java 专区,http://www-900.ibm.com/developerWorks/java/j-struts/index.shtml) Malcolm Davis顾问2001 年 2 月 内容&#xff1a; 简介 JSP 就是 servlet 别在我的 HTML 中使用太多的 Java MVC MVC Model 2 Struts 详细分析 Struts 邮件列表…

Struts,MVC 的一种开放源码实现用这种servlet和JSP框架管理复杂的大型网站

(转载自IBM developerWorks中国网站 java 专区,http://www-900.ibm.com/developerWorks/java/j-struts/index.shtml) Malcolm Davis顾问2001 年 2 月 内容&#xff1a; 简介 JSP 就是 servlet 别在我的 HTML 中使用太多的 Java MVC MVC Model 2 Struts 详细分析 Struts 邮件列表…

Struts,MVC 的一种开放源码实现用这种servlet和JSP框架管理复杂的大型网站

(转载自IBM developerWorks中国网站 java 专区,http://www-900.ibm.com/developerWorks/java/j-struts/index.shtml) Malcolm Davis顾问2001 年 2 月 内容&#xff1a; 简介 JSP 就是 servlet 别在我的 HTML 中使用太多的 Java MVC MVC Model 2 Struts 详细分析 Struts 邮件列表…

哪些权重7权重8的网站怎么做的!我的站就是这么做的!轻量级泛目录无需数据库适合所有网站所有cms只需要放在根目录即可

如题&#xff1a;哪些权重7 权重8的站都是怎么做上来的&#xff01; 疫情期间大家都不好赚钱&#xff0c;出不了门&#xff0c;我偶尔让朋友看了一下我的站&#xff01; 他也想做网站了&#xff0c;然后问我要插件&#xff01;先上图 https://www.bilibili.com/video/BV1me41…