静的WebサイトをAzureにGithubからDeployする

Summary

  • 静的WebサイトのホストにはAzure storageを使う。
  • GithubからのDeployにはGithub actionsを。

Azure storage

Webサイトを提供するためにAzure storageに直接アクセスしてもらうのは不思議な感じもするが、そういうものらしい。Azure web appsを使うにはこちら


StorageV2/StandardとしてStorage accountを作成する。その後、作られたリソースを開き、左のメニューからStatic websiteを選択してEnableする。

すると自動的に$webコンテナが作成され、表示されたURLにアクセスするとそのコンテナの中身が提供される。

Custom domainとSSLを使うためには、さらにAzure CDNを使う必要がある。それについてはまた次回。

Github Actions

次に、GithubからのDeployを設定する。これにはいろいろな方法があると思うが、今回はGithub actionsを使用する。やり方はいろいろあるが、今回はAzure CLIを使用した。


例えばこんな感じ。基本的にはドキュメント通り。$webやconnection stringへシングルクォーテーションを付けるのを忘れずに。Azure storageのConnection stringはGithubのsecretsとして登録した。これはProjectのSettingsページから登録できる。

# This workflow will build and push a node.js application to an Azure Storage on every push to the master branch.
on:
  push:
    branches:
      - master

env:
  NODE_VERSION: '12.x'

jobs:
  build-and-deploy:
    name: Build and Deploy
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@master
    - name: Use Node.js ${{ env.NODE_VERSION }}
      uses: actions/setup-node@v1
      with:
        node-version: ${{ env.NODE_VERSION }}
    - name: npm install, build, and test
      run: |
        # Build and test the project
        npm install
        npm run build
        npm run test --if-present
    - name: 'Deploy to Azure Storage'
      uses: azure/CLI@v1
      with:
        azcliversion: latest
        inlineScript: az storage blob upload-batch -d '$web' -s ./build --connection-string '${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}'

Comments

  1. We also provide many on line casino poker games, which give you the likelihood to check your expertise again the dealer, whereas additionally, you will discover games such as Sic Bo, 파라오카지노 Dragon Tiger, and Craps. Better yet, all the games at Spin Rio are cellular appropriate. This signifies that whether you want to play slots, card and desk games, stay dealer games, scratch playing cards, or anything else, you will discover all of your favourites on your mobile phone.

    ReplyDelete

Post a Comment

Popular posts from this blog

LinuxでUSBカメラ映像をストリーミングかつ録画する

Raspberry pi 4とUbuntu Server 20.04 64bitでRaspberry pi cameraを使う

WSL2上でSSH経由のSOCKSプロキシを作りWindowsから使う