LoginSignup
2
3

More than 5 years have passed since last update.

PTVSで作ったDjangoアプリをAzure上にデプロイ

Last updated at Posted at 2016-10-07

Visual Stadio2015上でDjangoを動かす

PTVSについて詳しくはこちらを参照してください。

Visual stadio2015にてDjangoプロジェクを作成します。
Views.py内のhomeをコメントアウトし、代わりにtest.htmlを呼び出すプログラムを書く。

Views.py
from django.template import RequestContext
from datetime import datetime

def home(request):
        assert isinstance(request, HttpRequest)
        return render(request,'app/test.html')
"""
def home(request):
    assert isinstance(request, HttpRequest)
    return render(
        request,
        'app/index.html',
        context_instance = RequestContext(request,
        {
            'title':'Home Page',
            'year':datetime.now().year,
        })
    )
“""

test.htmlを新規作成してみる。
【templates】➡️【app】➡️【test.html(Add/New Itemで新規作成する)】

test.html
<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8" />
    <title>test</title>
</head>
<body>
    <div>My Name is saiyuki1919</div>
    Can you ?
</body>
</html>

Runすると下のように表示される
1.png

Azure上にデプロイする

作成中のプロジェクトを右クリックし、【Pubulish】を選択
2.png

ここで、Microsoft Azure Web Appsを選択しPublishを押す
3.png

ここで、Newを押して新規作成する。
※既存のものでやったらエラーが起きてDjangoアプリを実行できなかった
4.png

Web App name: 任意
App Service plan: 新規作成
Database server: No databaseを選択
その他: 適当でOk
5.png

適当に確認したらPublishを選択し、デプロイが始まる。(基本的にそのままでよい)
6.png

管理ポータルにて
【App Service】➡️【WebApp】➡️【概要】➡️【URL】
last.png

URLをクリックしてWebブラウザでみると下のように先ほど作ったDjangoのWebAppを見ることができる。
7.png

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3