我使用Github Actionstry 了Azure功能部署,并取得了成功.
最初,当我部署该功能时,它是不可见的,请参阅以下内容:
确保您的init.py和unction.json位于一个目录中,而其他文件位于该目录之外,以使部署成功工作,请参阅以下内容:-
参考文献:-SO Thread由jseaske回答
现在,我使用Github操作部署了该功能,并且该功能在门户中可见,如下所示:
Refer my complete github workflow in this 100.
name: Build and deploy Python project to Azure Function App - siliconfunc12
on:
push:
branches:
- main
workflow_dispatch:
env:
AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
PYTHON_VERSION: '3.10' # set this to the python version to use (supports 3.6, 3.7, 3.8)
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Setup Python version
uses: actions/setup-python@v1
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Create and start virtual environment
run: |
python -m venv venv
source venv/bin/activate
- name: Install dependencies
run: pip install -r requirements.txt
# Optional: Add step to run tests here
- name: Upload artifact for deployment job
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-function.outputs.webapp-url }}
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v2
with:
name: python-app
path: .
- name: 'Deploy to Azure Functions'
uses: Azure/functions-action@v1
id: deploy-to-function
with:
app-name: 'siliconfunc12'
slot-name: 'Production'
package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_E640D92BF68849679F8A36682B022D5F }}
scm-do-build-during-deployment: true
enable-oryx-build: true
Output:-个
100
添加以下设置以从Zip运行您的功能应用程序:-
HTTPTrigger成功运行如下:-
您可以使用Github从部署中心直接运行您的功能应用程序部署,Github将自动创建Github工作流,并将您的功能触发器部署到功能应用程序,请参阅以下内容: