gpt4 book ai didi

azure - 将 Python 应用程序部署到 Azure 应用服务的 Github 工作流

转载 作者:行者123 更新时间:2023-12-02 23:54:41 25 4
gpt4 key购买 nike

我有一个requirements.txt,其内部依赖关系位于私有(private)Github存储库中。我已将工作流程的构建步骤设置为使用 webfactory/[email protected]提供在构建阶段完美运行的 SSH 身份验证。由于 SSH 问题,部署阶段无法进行身份验证,但当 Azure Oryx 在部署期间处理依赖项构建时,我找不到类似的方法来使 SSH 正常工作。

错误:

Python Version: /opt/python/3.7.12/bin/python3.7
Creating directory for command manifest file if it doesnot exist
Removing existing manifest file
Python Virtual Environment: antenv
Creating virtual environment...
Activating virtual environment...
Running pip install...
"2022-09-12 15:13:31"|ERROR|ERROR: Command errored out with exit status 128: git clone -q
'ssh://****@github.com/Murphy-Hoffman/IBMi-MHC.git' /tmp/8da94d13f03a38b/antenv/src/ibmi-mhc-
db2 Check the logs for full command output. | Exit code: 1 | Please review your
requirements.txt | More information: https://aka.ms/troubleshoot-python
\n/bin/bash -c "oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --
platform-version 3.7 -i /tmp/8da94d13f03a38b --compress-destination-dir -p
virtualenv_name=antenv --log-file /tmp/build-debug.log | tee /tmp/oryx-build.log ; exit
$PIPESTATUS "

Generating summary of Oryx build
Parsing the build logs
Found 1 issue(s)

Build Summary :
===============
Errors (1)
1. ERROR: Command errored out with exit status 128: git clone -q
'ssh://****@github.com/Murphy-Hoffman/IBMi-MHC.git' /tmp/8da94d13f03a38b/antenv/src/ibmi-mhc-
db2 Check the logs for full command output.
- Next Steps: Please review your requirements.txt
- For more details you can browse to https://aka.ms/troubleshoot-python

我的requirements.txt文件

autopep8==1.7.0
ibm-db==2.0.9
-e git+ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4c3cdd0e4c3cdd0ccd1c68ac7cbc9" rel="noreferrer noopener nofollow">[email protected]</a>/Murphy-Hoffman/IBMi-
MHC.git@57085a5e1f5637bfdd815397b45ba1b2dfd9b52c#egg=IBMi_MHC_db2&subdirectory=utility/db2
-e git+ssh://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="46212f3206212f322e33246825292b" rel="noreferrer noopener nofollow">[email protected]</a>/Murphy-Hoffman/IBMi-
MHC.git@57085a5e1f5637bfdd815397b45ba1b2dfd9b52c#egg=IBMi_MHC_UNIT&subdirectory=IBMi/_UNIT
itoolkit==1.7.0
pycodestyle==2.9.1
pyodbc==4.0.32
toml==0.10.2

最后,构建阶段成功但部署失败的 Github Action yml

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
# More info on Python, GitHub Actions, and Azure App Service: https://aka.ms/python-webapps-
actions

name: Build and deploy Python app to Azure Web App - mhc-customers

on:
push:
branches:
- main
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Set up Python version
uses: actions/setup-python@v1
with:
python-version: '3.7'

- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate

- name: Setup SSH for Private Repos
uses: webfactory/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="691a1a0144080e0c071d291f59475c475d" rel="noreferrer noopener nofollow">[email protected]</a>
with:
ssh-private-key: |
${{ secrets.IBMI_MHC_SECRET }}


- name: Install Dependencies
run: |
pip install -r requirements.txt

# Optional: Add step to run tests here (PyTest, Django test suites, etc.)

- name: Upload artifact for deployment jobs
uses: actions/upload-artifact@v2
with:
name: python-app
path: |
.
!venv/

deploy:
runs-on: ubuntu-latest
needs: build
environment:
name: 'Production'
url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}

steps:
- name: Setup SSH for Private Repos
uses: webfactory/<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="addedec580cccac8c3d9eddb9d83988399" rel="noreferrer noopener nofollow">[email protected]</a>
with:
ssh-private-key: |
${{ secrets.IBMI_MHC_SECRET }}

- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .

- name: 'Deploy to Azure Web App'
uses: azure/webapps-deploy@v2
id: deploy-to-webapp
with:
app-name: 'mhc-customers'
slot-name: 'Production'
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_89B81B4839F24A7589B3A4D5D845DA59 }}

最佳答案

我已经成功了 - 有点。在阅读了 Oryx 自动化构建平台 https://github.com/microsoft/Oryx 后我在运行此配置的应用程序根目录中添加了 appsvc.yaml:

version: 1

pre-build: |
git config --global url."https://{secret}@github".insteadOf https://github

问题是我们必须将实际的 Github secret 放入配置 yaml 中(代替“ secret ”)。这并不理想,但可以让 Oryx 使用正确的凭据。

关于azure - 将 Python 应用程序部署到 Azure 应用服务的 Github 工作流,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73691926/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com