I have a simple azure function app that I want to deploy via github pages, I'm trying to do it via: az functionapp deployment source config-zip
. This works well from my local windows machine:
C:\%APP_DEMO%>az functionapp deployment source config-zip -g WebApiDemoResourceGroup -n FunctionAppInstance1 --src functionapp.zip
but when I do it on github action like:
buildFunction:
runs-on: windows-latest
needs: prepareAzure
steps:
- uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Restore
run: dotnet restore "${{ env.FUNCTION_WORKING_DIRECTORY }}"
- name: Build
run: dotnet build "${{ env.FUNCTION_WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Publish
run: dotnet publish "${{ env.FUNCTION_WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}"
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: functionapp
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
deployFunction:
runs-on: windows-latest
needs: buildFunction
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: functionapp
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
- name: Azure Login
uses: azure/CLI@v1
with:
azcliversion: 2.47.0
inlineScript: |
az login --service-principal \
-u ${{ secrets.DEPLOYMENT_AZURE_CLIENT_ID }} \
-p ${{ secrets.DEPLOYMENT_AZURE_CLIENT_SECRET }} \
-t ${{ secrets.DEPLOYMENT_AZURE_TENANT_ID }}
- name: Deploy to Azure Function
uses: azure/CLI@v1
with:
azcliversion: 2.47.0
inlineScript: |
zip -r functionapp.zip .
groupName=${{ env.AZURE_GROUP_NAME }}
az functionapp deployment source config-zip -g $groupName -n ${{env.AZURE_FUNCTION_NAME}} --src functionapp.zip
I see that deployFunction
step is not failed, but in logs I see:
Run azure/CLI@v1
with:
azcliversion: 2.47.0
inlineScript: zip -r functionapp.zip .
groupName=%MyRG%
az functionapp deployment source config-zip -g $groupName -n %APP_NAME% --src functionapp.zip
env:
AZURE_GROUP_NAME: %MyRG%
AZURE_LOCATION: southcentralus
AZURE_WEBAPP_NAME: WebApiDemoWebApp
AZURE_WEBAPP_PACKAGE_PATH: WebApiDemo/publish
CONFIGURATION: Release
DOTNET_CORE_VERSION: 6.0.x
WORKING_DIRECTORY: WebApiDemo
FUNCTION_WORKING_DIRECTORY: %APP_DEMO%
AZURE_FUNCTION_NAME: %APP_NAME%
AZURE_FUNCTIONAPP_PACKAGE_PATH: %APP_DEMO%/published
Error: Please use Linux based OS as a runner.
Warning: Error: EPERM: operation not permitted, unlink 'D:\a\_temp'
cleaning up container...
how can I troubleshoot it? Even though the whole step is not failed, I don't see my deployed function on the portal.
Operating system I used for my fuction is Windows. I see it in the portal overview page:
Operating System
Windows
same I see in service plan:
Operating System
:
Windows
It might be related to this guard, but I have no ideas what it does mean.
I have azure function and web app in my resource group, if I switch azure function to linux, I see this error when I create web app (even before creating fuction):
"message":"Linux dynamic workers are not available in resource group WebApiDemoResourceGroup. Use this link to
. Something weird is going on..
I found few similar cases where in users facing the same issue. This seems to be a limitation.
Create a new resource group and try to create linux function app in that particular resource group in a different region.
Try to deploy your function app using GitHub-actions:
As, @Azeem mentioned, change runs-on:windows
to runs-on:ubuntu
in your workflow and deploy.
buildFunction:
runs-on: ubuntu-latest
needs: prepareAzure
steps:
- uses: actions/checkout@v3
- name: Setup .NET SDK
uses: actions/setup-dotnet@v3
with:
dotnet-version: ${{ env.DOTNET_CORE_VERSION }}
- name: Restore
run: dotnet restore "${{ env.FUNCTION_WORKING_DIRECTORY }}"
- name: Build
run: dotnet build "${{ env.FUNCTION_WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-restore
- name: Publish
run: dotnet publish "${{ env.FUNCTION_WORKING_DIRECTORY }}" --configuration ${{ env.CONFIGURATION }} --no-build --output "${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}"
- name: Publish Artifacts
uses: actions/upload-artifact@v3
with:
name: functionapp
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
deployFunction:
runs-on: ubuntu-latest
needs: buildFunction
steps:
- name: Download artifact from build job
uses: actions/download-artifact@v3
with:
name: functionapp
path: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
- name: Azure Login
uses: azure/CLI@v1
with:
azcliversion: 2.47.0
inlineScript: |
az login --service-principal \
-u ${{ secrets.DEPLOYMENT_AZURE_CLIENT_ID }} \
-p ${{ secrets.DEPLOYMENT_AZURE_CLIENT_SECRET }} \
-t ${{ secrets.DEPLOYMENT_AZURE_TENANT_ID }}
- name: Deploy to Azure Function
uses: azure/CLI@v1
with:
azcliversion: 2.47.0
inlineScript: |
zip -r functionapp.zip .
groupName=${{ env.AZURE_GROUP_NAME }}
az functionapp deployment source config-zip -g $groupName -n ${{env.AZURE_FUNCTION_NAME}} --src functionapp.zip
Alternative:
As you are facing issue while creating linux function app, you can try other way to deploy the function to windows function app.
Go to your function app in Azure portal=>Deployment=>Deployment center=> Settings=>
Select GitHub as source and provide the details of all other fields and save.
Once you click on save, it starts the deployment.
To check the deployment status, click on main=>It will be redirected to github=>click on Actions.
As shown below, GitHub actions deploys the function app using zip deployment.