Giter VIP home page Giter VIP logo

actions-workflow-samples's Introduction

Starter Action Workflows to deploy to Azure

GitHub Actions for Azure help you easily create workflows to build, test, package, release and deploy to Azure, following a push or pull request.

You use Azure starter templates present in this repo to easily create GitHub CI/CD workflows targeting Azure, to deploy your apps created with popular languages and frameworks such as .NET, Node.js, Java, PHP, Ruby or Python, in containers or running on any operating system.

Guidelines to select/author a new sample workflow

Folder Structure: These workflow samples to automate your deployment workflows targeting various Azure services are organized under folders of same names. For example: /AppService/asp.net-core-webapp-on-azure.yml

Naming Notation:

  • os-ecosystem-ServiceName-on-azure: example, linux-container-functionapp-on-azure.yml
  • OS in the name is optional if the action workflow sample is OS agnostic and doesnt significantly change between OS (Linux/Windows)
  • Ecosystem can be a language (.NET, Nodejs, java, Python, Ruby etc.) or Docker/Container Or Database flavours like SQL/MySQL etc.

Workflow structure

  • Include 'name' for every workflow to indicate the purpose of the workflow
  • Ensure that starter workflows run on: push by default.
  • For all secrets to be defined in the workflow, use UPPER_CASE with underscore delimiters instead of snake_case or camelCase.
  • Include a commented Configuration section which includes hyperlinks to documentation for the Actions used and other pre-reqs.
  • Define environment variables as part of configuration. We think this will help provide visibility into the things that need to be configured as part of te workflow.
  • Ensure all Azure actions referenced in the workflow are pointing to a released version of the action and not from the master. For list of all released GitHub actions for Azure, please refer to https://github.com/Azure/actions

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

actions-workflow-samples's People

Contributors

aksm-ms avatar apoorv33 avatar chrisreddington avatar dependabot[bot] avatar hazhzeng avatar joelbyford avatar kaverma avatar madhuv-msft avatar manojvazirani avatar manuelgalindo avatar maxheld83 avatar microsoft-github-policy-service[bot] avatar microsoftopensource avatar msftgits avatar n-usha avatar nenoloje avatar patelchandni avatar pulkitaggarwl avatar raiyanalam avatar ralarcon avatar sarmadjari avatar sgollapudi77 avatar shpraka avatar shubham805 avatar smpeters avatar suaggar avatar surenderssm avatar thesattiraju avatar tspascoal avatar vivishno avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

actions-workflow-samples's Issues

Full details for required Github Secret JSON

The current details don't seem to work with just top 4 secret properties in the readme:
https://github.com/Azure/actions-workflow-samples/blob/master/assets/create-secrets-for-GitHub-workflows.md

There are more details "(...)" that are omitted. Would be best to show all required fields so users can add existing service principals as Github secrets. Also note that the fields between Get-AzEnvironment and Az CLI commands return different property names for the same property. The names used in the JSON secret is also different from those two, so this can get confusing when user tries to figure out what properties is what.

{
    "clientId": "<GUID>",
    "clientSecret": "<GUID>",
    "subscriptionId": "<GUID>",
    "tenantId": "<GUID>",
    (...)
}

Deploy to web app does not working for .NET 8 and Linux based deployment - azure/webapps-deploy@v3

We are using GitHub Action for deploying to Azure Web App verison 3 - azure/webapps-deploy@v3. Detail about our WebApp:

Dotnet SDK version: .NET 8 - dotnet-version: 8.x
Platform: Linux

Below steps in our workflow not working:

- uses: azure/webapps-deploy@v3
      id: deploy-to-webapp
      with:
        app-name: ${{ vars.PP_NAME }}
        package: ${{ steps.download-artifact.outputs.download-path }}
        clean: false
        restart: false

Using azure/webapps-deploy@v3 - Github action getting below error:

##[debug]Initiated deployment via kudu service for webapp package : /home/runner/work/_temp/temp_web_package_7365615165970218.zip
Package deployment using OneDeploy initiated.
##[debug]setting affinity cookie ["ARRAffinity=*******;Path=/;HttpOnly;Secure;Domain=******.scm.azurewebsites.net","ARRAffinitySameSite=*****;Path=/;HttpOnly;SameSite=None;Secure;Domain=******.scm.azurewebsites.net"]
##[debug][POST] https://*******.scm.azurewebsites.net/api/publish?async=true&deployer=GITHUB_ONE_DEPLOY&type=zip&clean=false&restart=false&message=_______slotName%22%3A%22production%22%2C%22commitMessage_____
##[debug]encountered request timedout issue in Kudu. Retrying again
******
Error: Failed to deploy web package to App Service.
Error: Deployment Failed, Error: Failed to deploy web package using OneDeploy to App Service.
Conflict (CODE: 409)

As a workaround, we have tried by directly executing PowerShell command, but its also not working - by creating zip and provided zip file to deploy using Publish-AzWebApp PS command:

   - name: Create Zip
      shell: pwsh
      run: Compress-Archive -Path ${{ steps.download-artifact.outputs.download-path }} -Destinationpath ./myWebApp.zip

    - name: Run Azure PowerShell inline script
      uses: azure/powershell@v1
      with:
        inlineScript: |
          Publish-AzWebApp -ResourceGroupName ${{ vars.RG_NAME }} -Name ${{ vars.WEBAPP_NAME }} -ArchivePath ./myWebApp.zip -Timeout 1000000 -Confirm:$false -Force
        azPSVersion: "latest"

Using PowerShell command, its giving below error:

/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command $env:PSModulePath
/usr/share:/home/runner/.local/share/powershell/Modules:/usr/local/share/powershell/Modules:/opt/microsoft/powershell/7/Modules
Initializing Az Module Complete
Running Az PowerShell Script
/usr/bin/pwsh -NoLogo -NoProfile -NonInteractive -Command /home/runner/work/_temp/*****.ps1
Publish-AzWebApp: /home/runner/work/_temp/*****.ps1:2
Line |
   2 |  Publish-AzWebApp -ResourceGroupName rg-test -Name a …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Deployment failed with status code GatewayTimeout
Error: Error: The process '/usr/bin/pwsh' failed with exit code 1

It seems, there is an issue while deploying .NET 8 - ASP.NET Core Web application to Linux based App Service. Any workaround or solution will be helpful.

Checked /wwwroot directory using bash shell as well but it also empty.

Action for Deploying to Azure VM

I'm not finding an action yet for deploying an application to an Azure VM. Am I missing it, or is this something that will still be added?

Documentation?

Hi team,
How does this "Azure/functions-action@v1" action know which resource group to deploy to?
I only seem to have provided the azure function app name and where to get the function code from...
Is it figured out via the azure credentials or what?

multiple startup-command

How use multiple startup-command for container in the azure/webapps-deploy@v2 sections?
I tried with ' "" ; , and I get
Bad indentation of a mapping entry

I tried with && but I get the following error:
unexpected end of the stream within a double quoted scalar

Deploy derived from template runs succesful, still ModuleNotFoundError on Azure Web App

I use the given template for deploying to Azure Webapp through GH actions. Everything runs fine, but I still get ModuleNotFoundError when trying to access my website. My yaml:

name: My App
on:
  push:
    branches:
      - main
env:
  AZURE_WEBAPP_NAME: my-app
  AZURE_WEBAPP_PACKAGE_PATH: '.'
  PYTHON_VERSION: '3.8' # supports 3.6, 3.7, 3.8)
jobs:
  build-and-deploy-to-Azure:
    runs-on: ubuntu-latest
    steps:
    - name: 'Checkout GitHub Action'
      uses: actions/checkout@master
    - name: Setup Python ${{ env.PYTHON_VERSION }} Environment
      uses: actions/setup-python@v2
      with:
        python-version: ${{ env.PYTHON_VERSION }}
    - name: 'Install dependencies'
      run: |
        python -m pip install --upgrade pip
        git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github".insteadOf https://github
        pip install -r requirements.txt
    - name: 'Deploy to Azure WebApp'
      uses: azure/webapps-deploy@v2
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}
        publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}

But when I look in the log stream in our app, I see:

2021-02-15T16:51:47.899495269Z   File "/home/site/wwwroot/app.py", line 1, in <module>
2021-02-15T16:51:47.899499469Z     from sampling_app import app
2021-02-15T16:51:47.899503270Z   File "/home/site/wwwroot/sampling_app/__init__.py", line 2, in <module>
2021-02-15T16:51:47.899507570Z     from flask_login import LoginManager

But the module is definitely installed, when I look in the logs of GH actions:

Successfully installed Faker-6.1.1 Flask-1.1.2 Flask-Bcrypt-0.7.1 Flask-Bootstrap-3.3.7.1 Flask-Cors-3.0.10 Flask-Dropzone-1.5.4 Flask-Login-0.5.0 Flask-Mail-0.9.1 Flask-SQLAlchemy-2.4.4 Flask-WTF-0.14.3 Jinja2-2.11.3 MarkupSafe-1.1.1 SQLAlchemy-1.3.23 Six-1.15.0 WTForms-2.3.3 Werkzeug-1.0.1 bcrypt-3.2.0 blinker-1.4 cffi-1.14.5 click-7.1.2 dnspython-2.1.0 dominate-2.6.0 email-validator-1.1.2 et-xmlfile-1.0.1 idna-3.1 itsdangerous-1.1.0 jdcal-1.4.1 numpy-1.20.1 openpyxl-3.0.6 pandas-1.2.2 pycparser-2.20 pyodbc-4.0.30 python-dateutil-2.8.1 python-dotenv-0.15.0 pytz-2021.1 steekproef-0.0.1 text-unidecode-1.3 visitor-0.1.3 xlrd-2.0.1 xlsxwriter-1.3.7

What am I missing here? I hope I dont have to use azure/appservice-build@v2, because that way I am not sure how to install our pivate repo's, notice the line in our YAML:

git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github".insteadOf https://github

We use an ACCES_TOKEN to access our private repos in our CD.

[Function App] can I set multiple package?

I found that this Action-task deploy all files in the packagePath.
is there any way to deploy specific files and folders?

for example, I want to do sth like below one.
(I guess 'with' doesn't allow an array field though)

    - name: Azure Functions Action
      uses: Azure/[email protected]
      with:
        app-name: ${{ env.AZURE_WEBAPP_NAME }}
        publish-profile:  ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
        package:
          - dist/*
          - httpEvent/*

or, we can ignore the useless folders and files when zipping following by .funcignore.

Action for Deploying to Azure VM

I've been looking for information on how to deploy dockerized applications to an Azure VM. My search has led me to here what seems to be a dead-end. #32

Since I don't see an action for deploying to Azure virtual machines, I assume there is no action to deploy to Azure VMs. Is my assumption accurate? If so, and if there are no plans to support deploying an image or application to a virtual machine, feel free to close this issue.

Example for a go project?

Why would I use a Docker container for my function app here? https://github.com/Azure/actions-workflow-samples/blob/master/FunctionApp/linux-container-functionapp-on-azure.yml https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image appears to make everything more complicated/slow with a container build and store phase. I am puzzled why people do it.

I'm looking for a simple container image with func so I can do a make deploy from https://github.com/kaihendry/count/blob/azure-functions/.github/workflows/azure-func.yml

Is that possible?

azure/login@v1 fails with self-hosted runner

Hi,
I have just started using github actions with self-hosted runner and I am stucked at the azure login.
I get the following error message:

Run azure/login@v1
with:
creds: ***
enable-AzPSSession: true
environment: azurecloud
allow-no-subscriptions: false
C:\WINDOWS\system32\cmd.exe /D /S /C ""C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd" cloud set -n azurecloud"
Done setting cloud: "azurecloud"
Error: Az CLI Login failed. Please check the credentials. For more information refer https://aka.ms/create-secrets-for-GitHub-workflows
Error: Error: Error: The process 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin\az.cmd' failed with exit code 1

I have AZURE_CREDENTIALS as a secret with the following format:

{
"clientId": "xxxxx",
"clientSecret": "xxxxx",
"subscriptionId": "xxxxx",
"tenantId": "xxxx"
}

Do you have any suggestion what would be the reason? Is the secret badly formatted?
The service principal was created by our admin and I received the credentials from him, I can't create sp on the azure AD myself.

task in workflow file:

  • name: Login via Az module
    uses: azure/login@v1
    with:
    creds: '${{ secrets.AZURE_CREDENTIALS }}'
    enable-AzPSSession: true

Run Devops with variables

Hi,

I'm able to trigger the Devops pipeline, but I can't seem to get the variables working.
Using it like so:

runs-on: ubuntu-20.04
steps:
 - name: DevOps release trigger
   if: github.event_name == 'push'
   uses: Azure/pipelines@v1
   with:
    azure-devops-project-url: 'https://dev.azure.com/orgnization/project'
    azure-pipeline-name: 'Pipeline' # name of the Azure pipeline to be triggered
    azure-devops-token: '${{ secrets.AZURE_DEVOPS_TOKEN }}'
    azure-pipeline-variables: '{"Branch": "testbranch", "App.Name": "apptest"}' # optional stringified json

I can't get the variable values on the pipeline.

Have folders per service

With the addition of other Azure services, I believe a per service folder containing the samples for this service would enable users to easily find the samples that they want.
As for multi service actions it could be in a special folder.

Example for a Gradle project?

Nowadays more developers are using Gradle as the build tool for their Java projects. However, in webapp service, neither do the azure default GitHub action file nor the action-workflow-samples contain an example for Gradle GitHub action yml.

Will it be possible to add a sample Java project with Gradle and an example GitHub action yml?

How to deploy a build folder generated during compilation outside the root repository using Azure's github action

I have a repository with two folders in the root repository. One is for the frontend (React) and one for the backend.

I would like to deploy a build folder (the build folder is from the client folder) thats gets generated during the workflow job when running the command "npm build" inside the client directory. Is there any way i can grab that auto-generated folder instead of grabbing a folder from the repository itself?

Heres my current .yaml file:

# Docs for the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
# More GitHub Actions for Azure: https://github.com/Azure/actions
#

name: Build and deploy Node.js app to Azure Web App 


on:
  push:
    paths-ignore:
      - 'server/**'   # Only trigger the deployment if the client folder changed, soo ignore the server folder changes
    branches: [ master ]
  pull_request:
    branches: [ master ]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@master

    - name: Set up Node.js version
      uses: actions/setup-node@v1
      with:
        node-version: '12.x'

    - name: npm install, build, and test
      run: |
        cd client
        npm install
        npm run build  # I want to deploy the folder that this command generates! 

    - name: 'Deploy to Azure Web App'
      uses: azure/webapps-deploy@v1
      with:
        app-name: 'my-monolithic-repository'
        slot-name: 'production'
        publish-profile: ${{ secrets.AzureAppService }}
        package: ./theGeneratedFolder # I want to grab the build folder that got created during this job and not grab a folder from the repository 

I can only deploy the build folder with the latest changes if i push it to the repository and i would like to avoid building the web app and just deploy the folder that gets generated during this job. I cannot find a way to grab auto-generated files from this action. Sorry for my english and thanks!

How to use node 20.x?

When I execute a GitHub action, I get this warning message, I am not sure how I can resolve it as the Node version 16x does not seem to be configurable to a different one.

I have set my variables to:

env:
  NODE_VERSION: "20.x"

but it does not look like it solves the issue.

image

Action Taking 30+ Minutes

Hi,

Please let me know if this should be in a github-actions repo, but I am using the base config in the examples for NodeJS and our build/deploy is taking 30+ minutes every single time.

The Github Action gets stuck on Azure/functions-action@v1.

Any ideas why?

Here is my workflow.yml:

# Docs for the Azure Web Apps Deploy action: https://github.com/azure/functions-action
# More GitHub Actions for Azure: https://github.com/Azure/actions

name: Build and Deploy

on:
  push:
    branches:
      - development
  workflow_dispatch:

env:
  AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
  NODE_VERSION: '18.x' # set this to the node version to use (supports 8.x, 10.x, 12.x)

jobs:
  build-and-deploy:
    runs-on: windows-latest
    steps:
      - name: 'Checkout GitHub Action'
        uses: actions/checkout@v2

      - name: Setup Node ${{ env.NODE_VERSION }} Environment
        uses: actions/setup-node@v1
        with:
          node-version: ${{ env.NODE_VERSION }}

      - name: 'Resolve Project Dependencies Using Npm'
        shell: pwsh
        run: |
          pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}'
          npm install
          npm run build --if-present
          npm run test --if-present
          popd

      - name: 'Run Azure Functions Action'
        uses: Azure/functions-action@v1
        id: fa
        with:
          app-name: 'my-func'
          slot-name: 'Production'
          package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}
          publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE_DEV }}

And the Github Action debug logs below. It repeats this over and over:

##[debug]Deployment status: 1 'Building and Deploying 'a8c4f086abf04c2abeb4263447fe38d5'.'. retry after 5 seconds
##[debug]setting affinity cookie ["ARRAffinity=742cff616624b5c1aff4f543417be11e48cb7b9f10b45a143ff7ddcedc6fef4d;Path=/;HttpOnly;Secure;Domain=my-func.scm.azurewebsites.net","ARRAffinitySameSite=742cff616624b5c1aff4f543417be11e48cb7b9f10b45a143ff7ddcedc6fef4d;Path=/;HttpOnly;SameSite=None;Secure;Domain=my-func.scm.azurewebsites.net"]
##[debug][GET] https://my-func.scm.azurewebsites.net/api/deployments/latest?deployer=GITHUB_ZIP_DEPLOY_FUNCTIONS_V1&time=2023-05-24_18-31-48Z
##[debug]POLL URL RESULT: {"statusCode":202,"statusMessage":"Accepted","headers":{"content-length":"755","connection":"close","content-type":"application/json; charset=utf-8","date":"Wed, 24 May 2023 18:59:06 GMT","server":"Microsoft-IIS/10.0","cache-control":"no-cache","expires":"-1","location":"https://my-func.scm.azurewebsites.net/api/deployments/latest?deployer=GITHUB_ZIP_DEPLOY_FUNCTIONS_V1&time=2023-05-24_18-31-48Z","pragma":"no-cache","retry-after":"30","x-ms-request-id":"da171a94-b4ee-4bea-b699-ad6d8d01447d","x-aspnet-version":"4.0.30319","x-powered-by":"ASP.NET"},"body":{"id":"a8c4f086abf04c2abeb4263447fe38d5","status":1,"status_text":"Building and Deploying 'a8c4f086abf04c2abeb4263447fe38d5'.","author_email":"N/A","author":"N/A","deployer":"GITHUB_ZIP_DEPLOY_FUNCTIONS_V1","message":"{\"type\":\"deployment\",\"sha\":\"89a11cc5b0e874124e291836bd7e1eba2ddc46ab\",\"repoName\":\"method-inc/falcon-mft-project-svc\",\"actor\":\"<my-name>\",\"slotName\":\"production\"}","progress":"Running deployment command...","received_time":"2023-05-24T18:32:23.5766618Z","start_time":"2023-05-24T18:32:24.6246668Z","end_time":null,"last_success_end_time":null,"complete":false,"active":false,"is_temp":false,"is_readonly":true,"url":null,"log_url":null,"site_name":"my-func","provisioningState":"InProgress"}}

Error in pythonazuredeploy.yml

Steps to reproduce
Copy and commit pythonazuredeploy.yml workflow file

The workflow stops with the below error

Invalid workflow file : .github/workflows/pythonazuredeploy.yml#L22
The workflow is not valid. .github/workflows/pythonazuredeploy.yml (Line: 22, Col: 1): 'name' is already defined

GitHub Actions to push to Azure Artifacts: Unable to load the service index for source ' 'Response status code does not indicate success: 401 (Unauthorized)

I wanted to create a Github workflow that push feed to Azure Artifacts. I carefully followed the article here and the tutorial here. However, I keep getting this error

error: Unable to load the service index for source https://pkgs.dev.azure.com/<org>/<proj>/_packaging/<proj>/nuget/v3/index.json. error: Response status code does not indicate success: 401 (Unauthorized).

I created a PAT for all accessible organizations, granted it full access and added it in my Github Action secrets just the docs says but the persists. Does anyone have idea what could be wrong here?

How to pull docker image tagged with SHA8

The docker sample pulls an image tagged with a complete sha by ${{ github.sha }}.

I tried ${{ git rev-parse --short }} ${{ github.sha::8 }} other attempts, not urgent, I just changed my image tagging to full SHA.

Action hanging when deploying function

When using the functions action V1 to deploy to my production function on windows, the action hangs when spinning up the function. Logs here:

##[Initialize]
##[ValidateParameter]
##[ValidateAzureResource]
Using RBAC for authentication, GitHub Action will perform resource validation.
Sucessfully acquired site configs from function app!
Detected function app sku: Consumption
Sucessfully acquired app settings from function app (RBAC)!
Detected function app language: Dotnet
##[PreparePublishContent]
Will archive . into d:\a_temp\temp_web_package_6845877634426281.zip as function app content
Will use api/zipdeploy to deploy (rbac authentication)
##[PublishContent]
Waiting for function app to spin up after app settings change.

I've let it run for in excess of five minutes with no sign of it deploying the zipped files.

Update az cli command to generate AZURE_CREDENTIALS

The script to generate AZURE_CREDENTIALS needs to be updated. --sdk-auth is depreciated and no longer required.

New script should look like this

   az ad sp create-for-rbac --name  myApp --role contributor \
                            --scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group} \         

usr/local/tomcat/webapps/ROOT/WEB-INF folder remains empty from GITHub Actions Java Web App deploy

I am Deploying a Simple Java Web App in Azure App Service using GitHub Actions workflow file.
App Service is running on Java11/Tomcat 9.0 stack.

Java Code > https://github.com/BasujitaBhattacharya/JavaWebApp.

The artefacts generated after the mvn clean install has the classes and lib folder generated inside the snapshot war.
However, after the deploy action when my webapp failed to function as expected,
I connected to the container via ssh and found that WEB-INF folder is empty.

The folder structure should be WEB-INF\classes\com\valeykey\frontend.
The class files must be inside this directory structure.

Any insights will be really helpful, thanks in advance.

Below is my GH Actions workflow file >

name: Build and deploy WAR app to Azure Web App - JavaWebAppfromPortal

name: Build and deploy JAR app to Azure Web App

env:
JAVA_VERSION: '11' # set this to the Java version to use
DISTRIBUTION: microsoft # set this to the Java distribution
AZURE_WEBAPP_PACKAGE_PATH : ./AppService/JavaWebApp

on:
push:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
build:
runs-on: ubuntu-latest

steps:
  - uses: actions/checkout@v3

  - name: Set up Java version
    uses: actions/[email protected]
    with:
      java-version: ${{ env.JAVA_VERSION }}
      distribution: ${{ env.DISTRIBUTION }}
      cache: 'maven'

  - name: Build with Maven
    run: mvn clean install
    working-directory: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

  - name: Upload artifact for deployment job
    uses: actions/upload-artifact@v3
    with:
      name: java-app
      path: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/target/*.war'

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

steps:
  - name: Download artifact from build job
    uses: actions/download-artifact@v3
    with:
      name: java-app
  - run: ls
  
  - name: Deploy to Azure Web App
    id: deploy-to-webapp
    uses: azure/webapps-deploy@v2
    with:
      app-name: ${{ secrets.APP_SERVICE_NAME }}
      publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
      package: '*.war'

Permission denied error

I tried the proposed blog method and I run into an error I am not sure how to solve:

  with:
    name: sampling-app
    path: .
  env:
    AZURE_WEBAPP_NAME: sampling-app
    AZURE_WEBAPP_PACKAGE_PATH: .
    RESOURCE_GROUP: zypp-general
    PYTHON_VERSION: 3.8
    pythonLocation: /opt/hostedtoolcache/Python/3.8.8/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.8.8/x64/lib
Starting download for sampling-app
Directory structure has been setup for the artifact
Total number of files that will be downloaded: 2000
events.js:187
      throw er; // Unhandled 'error' event
      ^

Error: EACCES: permission denied, open '/home/runner/work/sampling-app/sampling-app/.git/objects/pack/pack-acef06006e22da059b09e712a877695fbd811483.idx'
Emitted 'error' event on WriteStream instance at:
    at internal/fs/streams.js:294:12
    at FSReqCallback.oncomplete (fs.js:146:23) {
  errno: -13,
  code: 'EACCES',
  syscall: 'open',
  path: '/home/runner/work/sampling-app/sampling-app/.git/objects/pack/pack-acef06006e22da059b09e712a877695fbd811483.idx'
}

here is my YAML:

name: Build and deploy Sampling App

on:
  push:
    branches:
      - main

env:
  WEBAPP_NAME: 'sampling-app'
  RESOURCE_GROUP: 'zypp-general'
  PYTHON_VERSION: '3.8' # supports 3.6, 3.7, 3.8)

jobs:
  build-and-test:
    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2

    - name: Setup Python ${{ env.PYTHON_VERSION }} Environment
      uses: actions/setup-python@v2
      with:
        python-version: ${{ env.PYTHON_VERSION }}

    - name: Create and start virtual environment
      run: |
        python3 -m venv venv
        source venv/bin/activate
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip
        git config --global url."https://${{ secrets.ACCESS_TOKEN }}@github".insteadOf https://github
        pip install -r requirements.txt

    - name: Upload artifact for deployment jobs
      uses: actions/upload-artifact@v2
      with:
        name: ${{ env.AZURE_WEBAPP_NAME }}
        path: |
          .
          !venv/

  deploy-to-webapp:
    needs: build-and-test
    runs-on: ubuntu-latest

    steps:
      - uses: actions/download-artifact@v2
        with:
          name: ${{ env.AZURE_WEBAPP_NAME }}
          path: .

      - name: Log in to Azure CLI
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_SERVICE_PRINCIPAL }}

      - name: Configure deployment and runtime settings on the webapp
        run: |
          az configure --defaults ${{ env.RESOURCE_GROUP }}
          az webapp config appsettings --name ${{ env.AZURE_WEBAPP_NAME }} --settings \
              SCM_DO_BUILD_DURING_DEPLOYMENT=true \
              FLASK_ENV=production
          az webapp config set --name ${{ env.AZURE_WEBAPP_NAME }} \
            --startup-file "gunicorn --bind=0.0.0.0 --timeout 600 app:app"
      - name: Deploy to App Service
        uses: azure/webapps-deploy@v2
        with:
          app-name: ${{ env.AZURE_WEBAPP_NAME}}

Is there anything I am doing wrong here? The error is hard for me to understand. Seems like a permission thing on folder level?

cant run command: sudo apt-get python3.6-dev

Hi there,

I cannot deploy due to needing some c compiler files that are available in python3.6-dev
You cannot pip install them so you must apt-get.
The Actions deployment complains about stability of the cli etc.
What is the correct way to get this installed so I can take care of the dependencies that keep breaking in my requirements.txt

My yaml is as follows:
.github/workflows/master-appName(production).yml

    name: Azure App Service - appName(Production), Build and deploy Python app
    
    on:
      push:
        branches:
          - master
    
    jobs:
      build-and-deploy:
        runs-on: ubuntu-latest
    
        steps:
        # checkout the repo
        - name: 'Checkout Github Action'
          uses: actions/checkout@master
    
    
        - name: Set up Python version
          uses: actions/setup-python@v1
          with:
            python-version: '3.6'
    
        - name: apt get python 3.6-dev and shap
          run: |
            sudo apt-get install python3.6-dev
            pip install shap
    
        - name: Build using AppService-Build
          uses: azure/appservice-build@v2
          with:
            platform: python
            platform-version: '3.6'

6

��€э��€э

python pipeline - build issue with pycairo and wheel

Hello,

On the Deploy to Azure Web App pipeline, I have an issue during the build of the library pycairo. I initially run all my tests using also linux-latest + venv without any issue. However, after the "build artifact creation", I have the following step(auto-generated in Azure) :

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

And here is the error (simplified):

Package deployment using ZIP Deploy initiated.
Updating submodules.
Preparing deployment for commit id '6a[9](https://github.com/Coni63/codingame-readme-stats/actions/runs/3830803586/jobs/6519141948#step:3:10)e1c57-4'.
PreDeployment: context.CleanOutputPath False
PreDeployment: context.OutputPath /home/site/wwwroot
Repository path is /tmp/zipdeploy/extracted
Running oryx build...
Command: oryx build /tmp/zipdeploy/extracted -o /home/site/wwwroot --platform python --platform-version 3.[10](https://github.com/Coni63/codingame-readme-stats/actions/runs/3830803586/jobs/6519141948#step:3:11) -p virtualenv_name=antenv --log-file /tmp/build-debug.log  -i /tmp/8daeda0374b72e5 --compress-destination-dir | tee /tmp/oryx-build.log
Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
You can report issues at https://github.com/Microsoft/Oryx/issues

Oryx Version: 0.2.20220825.1, Commit: 24032445dbf7bf6ef068688f1b123a7144453b7f, ReleaseTagName: 20220825.1

Build Operation ID: |P9tGMmVKHdk=.f0177919_
Repository Commit : 6a9e1c57-41cf-4ccb-a3e9-2df5d8ca2f90

Detecting platforms...
Detected following platforms:
  python: 3.10.8
Version '3.10.8' of platform 'python' is not installed. Generating script to install it...

Using intermediate directory '/tmp/8daeda0374b72e5'.

Copying files to the intermediate directory...
Done in 0 sec(s).

Source directory     : /tmp/8daeda0374b72e5
Destination directory: /home/site/wwwroot


Downloading and extracting 'python' version '3.10.8' to '/tmp/oryx/platforms/python/3.10.8'...
Detected image debian flavor: bullseye.
Downloaded in 2 sec(s).
Verifying checksum...
Extracting contents...
performing sha512 checksum for: python...
Done in 14 sec(s).

image detector file exists, platform is python..
OS detector file exists, OS is bullseye..
Python Version: /tmp/oryx/platforms/python/3.10.8/bin/python3.10
Creating directory for command manifest file if it does not exist
Removing existing manifest file
Python Virtual Environment: antenv
Creating virtual environment...
Activating virtual environment...
Running pip install...

[...]

[15:36:42+0000] Collecting pycairo==1.23.0
[15:36:42+0000]   Downloading pycairo-1.23.0.tar.gz (344 kB)
[15:36:42+0000]      ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 344.6/344.6 kB 4.4 MB/s eta 0:00:00
[15:36:42+0000]   Installing build dependencies: started
[15:36:47+0000]   Installing build dependencies: finished with status 'done'
[15:36:47+0000]   Getting requirements to build wheel: started
[15:36:48+0000]   Getting requirements to build wheel: finished with status 'done'
[15:36:48+0000]   Installing backend dependencies: started
[15:36:50+0000]   Installing backend dependencies: finished with status 'done'
[15:36:50+0000]   Preparing metadata (pyproject.toml): started
[15:36:51+0000]   Preparing metadata (pyproject.toml): finished with status 'done'

[...]

[15:36:53+0000] Building wheels for collected packages: pycairo
[15:36:53+0000]   Building wheel for pycairo (pyproject.toml): started
[15:36:54+0000]   Building wheel for pycairo (pyproject.toml): finished with status 'error'
  error: subprocess-exited-with-error
  
  × Building wheel for pycairo (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [15 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.linux-x86_64-cpython-310
      creating build/lib.linux-x86_64-cpython-310/cairo
      copying cairo/__init__.py -> build/lib.linux-x86_64-cpython-310/cairo
      copying cairo/__init__.pyi -> build/lib.linux-x86_64-cpython-310/cairo
      copying cairo/py.typed -> build/lib.linux-x86_64-cpython-310/cairo
      running build_ext
      Package cairo was not found in the pkg-config search path.
      Perhaps you should add the directory containing `cairo.pc'
      to the PKG_CONFIG_PATH environment variable
      No package 'cairo' found
      Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.
      [end of output]
  
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pycairo
[15:36:54+0000] Failed to build pycairo
ERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects

Notice:  A new release of pip available: 22.2.2 -> 22.3.1
Notice:  To update, run: pip install --upgrade pip

Notice:  To update, run: pip install --upgrade pip | 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.10 -p virtualenv_name=antenv --log-file /tmp/build-debug.log  -i /tmp/8daeda0374b72e5 --compress-destination-dir | tee /tmp/oryx-build.log ; exit $PIPESTATUS "

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

Build Summary :
===============
Errors (1)

[...]

[15:36:[53](https://github.com/Coni63/codingame-readme-stats/actions/runs/3830803586/jobs/6519141948#step:3:54)+0000] Building wheels for collected packages: pycairo\n[15:36:53+0000]   Building wheel for pycairo (pyproject.toml): started\n[15:36:[54](https://github.com/Coni63/codingame-readme-stats/actions/runs/3830803586/jobs/6519141948#step:3:55)+0000]   Building wheel for pycairo (pyproject.toml): finished with status 'error'\n  error: subprocess-exited-with-error\n  \n  × Building wheel for pycairo (pyproject.toml) did not run successfully.\n  │ exit code: 1\n  ╰─> [15 lines of output]\n      running bdist_wheel\n      running build\n      running build_py\n      creating build\n      creating build/lib.linux-x86_[64](https://github.com/Coni63/codingame-readme-stats/actions/runs/3830803586/jobs/6519141948#step:3:65)-cpython-310\n      creating build/lib.linux-x[86](https://github.com/Coni63/codingame-readme-stats/actions/runs/3830803586/jobs/6519141948#step:3:87)_64-cpython-[310](https://github.com/Coni63/codingame-readme-stats/actions/runs/3830803586/jobs/6519141948#step:3:311)/cairo\n      copying cairo/__init__.py -> build/lib.linux-x86_64-cpython-310/cairo\n      copying cairo/__init__.pyi -> build/lib.linux-x86_64-cpython-310/cairo\n      copying cairo/py.typed -> build/lib.linux-x86_64-cpython-310/cairo\n      running build_ext\n      Package cairo was not found in the pkg-config search path.\n      Perhaps you should add the directory containing `cairo.pc'\n      to the PKG_CONFIG_PATH environment variable\n      No package 'cairo' found\n      Command '['pkg-config', '--print-errors', '--exists', 'cairo >= 1.15.10']' returned non-zero exit status 1.\n      [end of output]\n  \n  note: This error originates from a subprocess, and is likely not a problem with pip.\n  ERROR: Failed building wheel for pycairo\n[15:36:54+0000] Failed to build pycairo\nERROR: Could not build wheels for pycairo, which is required to install pyproject.toml-based projects\n\n[notice] A new release of pip available: 22.2.2 -> 22.3.1\n[notice] To update, run: pip install --upgrade pip  
-  Next Steps: Please review your requirements.txt
-  For more details you can browse to https://aka.ms/troubleshoot-python

Warnings (0)

Deployment Failed. deployer = GITHUB_ZIP_DEPLOY deploymentPath = ZipDeploy. Extract zip. Remote build.
Error: Failed to deploy web package to App Service.
Error: Deployment Failed with Error: Package deployment using ZIP Deploy failed. Refer logs for more details.
App Service Application URL: https://codingame-readme-stats.azurewebsites.net/

I found on this link some commands but how can I add them in the pipeline ?

pip install --upgrade pip
pip install --upgrade setuptools wheel

Should I copy-paste the whole [python.yml](https://github.com/Azure/actions-workflow-samples/blob/master/AppService/python-webapp-on-azure.yml) instead of the preconfigured command from azure ?

Many thanks in advance

deployment history in portal?

This probably isn't precisely the right place for this question, for which I apologize in advance.

I've configured the action successfully and it reports deployment success. However, because I didn't configure it through the Deployment Center in the portal for my function app, I can't see deployment history in the Azure portal to know it really, really worked. :)

Is there a way to see deployment history that I'm missing?

python github action template not working Publish Profile with Error: Failed to deploy web package to App Service.



Done in 43 sec(s).
Running post deployment command(s)...
Triggering recycle (preview mode disabled).
Linux Consumption plan has a 1.5 GB memory limit on a remote build container.
To check our service limit, please visit https://docs.microsoft.com/en-us/azure/azure-functions/functions-scale#service-limits
Creating placeholder blob for linux consumption function app...
Malformed SCM_RUN_FROM_PACKAGE when uploading built content.
Error: Failed to deploy web package to App Service.
Error: Execution Exception (state: PublishContent) (step: Invocation)
Error:   When request Azure resource at PublishContent, zipDeploy : Failed to use /home/runner/work/_temp/temp_web_package_5469774492953343.zip as ZipDeploy content
Error:     Package deployment using ZIP Deploy failed. Refer logs for more details.
Error: Deployment Failed!

my yml is simple demo adjustment with name ,
https://github.com/wanghaisheng/TiktokaTikTokVideoDownloadTookit/blob/main/.github/workflows/azure-function-python.yml

project root directory like this
-.github/workflows
-azure_func contain init.py and function.json
-host.json

i can run locally with func start

structured data support with GitHub secrets

👋 Hi all - the following document suggested storing Azure credentials as a secret in JSON format.

https://github.com/Azure/actions-workflow-samples/blob/master/assets/create-secrets-for-GitHub-workflows.md#set-secret-with-azure-credentials

Store the above JSON as the value of a GitHub secret with a name, for example 'AZURE_CREDENTIALS'

Unfortunately this information is incorrect, as GitHub does not support JSON or any structured data for secrets.

https://docs.github.com/en/actions/reference/encrypted-secrets#naming-your-secrets

To help ensure that GitHub redacts your secret in logs, avoid using structured data as the values of secrets. For example, avoid creating secrets that contain JSON or encoded Git blobs.

Could someone please update the document to reflect these limitations. Thanks! 🙇

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.