0cbcc5436e | ||
---|---|---|
.github/workflows | ||
lib | ||
src | ||
.gitignore | ||
.nycrc | ||
CODE_OF_CONDUCT.md | ||
LICENSE | ||
README.md | ||
SECURITY.md | ||
action.yml | ||
package-lock.json | ||
package.json | ||
tsconfig.json |
README.md
IMPORTANT NOTICE:
This action is ARCHIVED and will not receive any updates. Please update your existing workflows to use the action azure/webapps-deploy@v2 which can deploy to both Webapps and Webapp for containers. Refer to https://github.com/Azure/webapps-deploy for more details about the action.
For example, the action azure/webapps-container-deploy@v1
should be replaced with azure/webapps-deploy@v2
in your workflows.
GitHub Action for deploying to Azure Web App for Containers
GitHub Actions gives you the flexibility to build an automated software development lifecycle workflow.
You can automate your workflows to deploy Azure Web Apps for Containers using GitHub Actions.
Get started today with a free Azure account!
If you are looking for a Github Action to deploy to an Azure WebApp (Windows or Linux) or Azure WebApp for Containers (single container image or multiple containers), consider using Azure WebApp action.
For deploying container images to Kubernetes, consider using Kubernetes deploy action. This action requires that the cluster context be set earlier in the workflow by using either the Azure/aks-set-context action or the Azure/k8s-set-context action.
End-to-End Sample Workflows
Dependencies on other Github Actions
- Checkout Checkout your Git repository content into Github Actions agent.
- Azure Login Login with your Azure credentials for Web app deployment authentication. Once login is done, the next set of Azure actions in the workflow can re-use the same session within the job.
- docker-login : Actions to log in to a private container registry such as Azure Container registry. Once login is done, the next set of Actions in the workflow can perform tasks such as building, tagging and pushing containers.
Azure Service Principle for RBAC
For using any credentials like Azure Service Principal in your workflow, add them as secrets in the GitHub repository and then refer them in the workflow.
- Download Azure CLI from here, run
az login
to login with your Azure credentials. - Run Azure CLI command to create an Azure Service Principal for RBAC:
az ad sp create-for-rbac --name "myApp" --role contributor \
--scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group} \
--sdk-auth
# Replace {subscription-id}, {resource-group} with the subscription, resource group details of the WebApp
# The command should output a JSON object similar to this:
{
"clientId": "<GUID>",
"clientSecret": "<GUID>",
"subscriptionId": "<GUID>",
"tenantId": "<GUID>",
(...)
}
- You can further scope down the Azure Credentials to the Web App using scope attribute. For example,
az ad sp create-for-rbac --name "myApp" --role contributor \
--scopes /subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.Web/sites/{app-name} \
--sdk-auth
# Replace {subscription-id}, {resource-group}, and {app-name} with the names of your subscription, resource group, and Azure Web App.
- Paste the json response from above Azure CLI to your Github Repository > Settings > Secrets > Add a new secret > AZURE_CREDENTIALS
- Now in the workflow file in your branch:
.github/workflows/workflow.yml
replace the secret in Azure login action with your secret (Refer to the example below)
Build and deploy a Node.js app to Azure WebApp Container
on: [push]
name: Linux_Container_Node_Workflow
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# checkout the repo
- name: 'Checkout Github Action'
uses: actions/checkout@master
- name: 'Login via Azure CLI'
uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
- uses: azure/docker-login@v1
with:
login-server: contoso.azurecr.io
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- run: |
docker build . -t contoso.azurecr.io/nodejssampleapp:${{ github.sha }}
docker push contoso.azurecr.io/nodejssampleapp:${{ github.sha }}
- uses: azure/webapps-deploy@v2
with:
app-name: 'node-rnc'
images: 'contoso.azurecr.io/nodejssampleapp:${{ github.sha }}'
- name: Azure logout
run: |
az logout
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 opencode@microsoft.com with any additional questions or comments.