0
0

Azure DevOps の Azure Pipelines で Sphinx ドキュメント を生成して Azure App Service で公開する

Last updated at Posted at 2023-10-16

目次

  1. Azure Repos にSphinx ドキュメント を用意する
  2. Azure App Service を作成する
  3. Azure DevOps と Azure Subscription を接続する
  4. Azure Pipelines で html を生成して、Azure App Serviceへデプロイする
  5. トラブルシューティング

手順

1. Azure Repos にSphinx ドキュメント を用意する

  1. Azure Repos に SphinxをインストールしているPythonモジュール を格納する。
    a. ここでは例としてDjangoをimportして使用する。image.png

2. Azure App Service を作成する

  1. App Service で検索してクリックimage.png

  2. 作成 -> Web アプリ
    image.png

  3. 各項目を入力する。命名はMicrosoftのベストプラクティスに従う。image.png
    今回使用した省略形↓↓

    リソース 省略形
    Resource group rg
    App Service プラン asp
    Web アプリ app
    東日本 jpe

    ※GeoCodeはここに記載

  4. ドキュメントの閲覧ができなくても影響は少ないため、Application Insights は無効にするimage.png

  5. 設定を確認して作成
    image.png

3. Azure DevOps と Azure Subscriptionを接続する

  1. Project settings -> Service connections -> Create service connection -> Azure Resource Managerimage.png
  2. Workload Identity federation (automatic) image.png
  3. ポップアップ画面が表示されるので、Azure Subscriptionに紐づくアカウントで認証する。※表示されないとき
  4. Resource groupは空欄のままにし、Service connection name を入力し、Grant access permission to all pipelines にチェックを入れSaveする
    image.png

4. Azure Pipelines で html を生成して、Azure App Serviceへデプロイする

  1. Pipelines -> Create Pipeline -> Azure Repos Git -> study -> Starter pipline -> Show assistant -> Azure App Service deploy image.png
  2. 前の手順で作成したApp Serviceを選択する
    image.png
  3. ymlを書き換えて、Save and Run ※エラーが出たとき
trigger:
- main

pool:
  vmImage: windows-latest

steps:
- script: |
    pip install Sphinx
    cd django/docs/
    make html
  displayName: 'Make html'
- task: ArchiveFiles@2
  inputs:
    rootFolderOrFile: 'django/docs/'
    includeRootFolder: false
    archiveType: 'zip'
    archiveFile: '$(System.DefaultWorkingDirectory)/$(Build.BuildId).zip'
    replaceExistingArchive: true
- task: AzureRmWebAppDeployment@4
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'Azure subscription 1 connection'
    appType: 'webApp'
    WebAppName: 'app-study-prod-jep-001'
    packageForLinux: '$(System.DefaultWorkingDirectory)/*.zip'

5.トラブルシューティング

表示されないとき

ポップアップ表示されなけばWebブラウザのアドレスバーにあるポップアップブロック表示をクリックし、ブロックを解除して表示させる。何らかのResource group名が表示されれば認証済みである。(このとき未認証状態だと空欄のままとなる)
image.png

エラーが出たとき

下記のエラーが出たら、メッセージに記載のURLから無料利用をリクエストする。(マイニング利用防止のために制限がかかっている。)

##[error]No hosted parallelism has been purchased or granted. To request a free parallelism grant, please fill out the following form https://aka.ms/azpipelines-parallelism-request
0
0
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
0
0