Coder Social home page Coder Social logo

container-app-job's Introduction

Container Apps Jobs

References:

Run and test it locally

Using npm:

cd src
URL="https://reqres.in/api/users?page=2"
npm run start

Or using Docker:

cd src
docker build -t myjob .
docker run -e URL="https://stackoverflow.com" myjob

Prepare it first for GitHub Actions

Before you will be able to run GitHub Actions to deploy Container Apps, you need to have the following:

  • A GitHub repository with the source code of your app
  • An Azure service principal and the credentials for authentication with Azure. It will be used by GitHub Actions to deploy the Container Apps
  • A secret in the GitHub repository to store the Azure service principal credentials
  • An Azure Resource Group where to deploy Container Apps
  • An Azure Container Registry to store the container images of the Container Apps

Create Azure infra resources

The following script creates a new Service Principal, a new Resource Group and a Container Registry for container images. The new Resource Group will be used to deploy the Container Registry resource as well as the Container Apps.

You can edit the variables inside the script to customize the names of the resources being created.

cd scripts
az login
./initial-setup.sh

This command will output a file auth.json with the service principal credentials that will be used later for the Github Secrets.

Create the GitHub repository

Example:

alt text

Create environment secrets and variables used by GitHub Actions

In the GitHub repository, go to "Settings > Code and automation > Environments" and create a new environment with the name azure.

alt text

Under this environment, add a new secret with the name AZURE_CREDENTIALS and the content of the auth.json file.

alt text

And create the following variables:

  • RESOURCE_GROUP: the resource group name where the container app will be deployed (e.g., aca-rg-02)
  • LOCATION: the Azure region where the resources will be deployed (e.g., westeurope)
  • CONTAINER_REGISTRY_NAME: the name of the Azure Container registry to be created/used to store container images (.e.g., rfpacr02)
  • JOB_NAME: the name of the container app job to be deployed (e.g., aca-gh-actions-02)
  • JOB_IMAGE_NAME: the name of the container image to build and push (e.g., triggerjob)
  • JOB_CRON_EXPRESSION: the cron expression for the schedule trigger (e.g., * */10 * * *)

Example:

alt text

Commit and push everything...*

Finally, commit and push everything to the new repository. Push will trigger 1 action:

  • build-and-deploy.yaml that will deploy a new Container App Job to Azure

container-app-job's People

Watchers

Rui Félix Pereira avatar

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.