简体   繁体   English

在 Azure 上部署 React - django 应用 web 应用

[英]Deploying React - django apps on Azure web apps

Locally, I am able to run my django app and react app.在本地,我能够运行我的 django 应用程序和 React 应用程序。 I migrated the django app to the azure web apps.我将 django 应用程序迁移到 azure web 应用程序。 My question is, what is best practice regarding connecting the react app to the django app.我的问题是,将 React 应用程序连接到 django 应用程序的最佳做法是什么。 Should I start another web app instance, or should I try to run both on the same instance?我应该启动另一个 web 应用程序实例,还是应该尝试在同一个实例上运行这两个应用程序实例?

The easiest way is that both React and Django are deployed on the same instance, however it depends on your need.最简单的方法是将 React 和 Django 部署在同一个实例上,但这取决于您的需要。

There are many ways to deploy Django + React, I will mentioned only two: Django+React的部署方式有很多种,这里只提两种:

  1. Simple one: Just import react libraries into your Django template and deploy your Django on the instance as a normal Django project.简单的一个:只需将 React 库导入您的 Django 模板并将您的 Django 作为普通的 Django 项目部署在实例上。 You may refer to this tutorial on how to accomplish this: Add React to Django Template您可以参考本教程了解如何完成此操作: Add React to Django Template

  2. Second way which I would recommend: Deploy Django and React separately.我推荐的第二种方式:分别部署 Django 和 React。 Django app to be deployed on the Azure instance and react to be deployed as a static website on Azure Blob storage (You may refer to this tutorial: Host React on Azure Blob ). Django app部署在Azure实例上,react作为static网站部署在Azure Blob存储上(可参考教程: Host React on Azure Blob )。 In this case, your react app will be using the Django exposed APIs (through Django DRF).在这种情况下,您的 React 应用程序将使用 Django 公开的 API(通过 Django DRF)。 You may refer to this tutorial for further details: Deploy React + Django您可以参考本教程了解更多详情: Deploy React + Django

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM