0.1.113 • Published 5 months ago

@azbake/ingredient-utils v0.1.113

Weekly downloads
187
License
MIT
Repository
github
Last release
5 months ago

Changelogs

Tools

lerna

Generic badge

Build

Build Commands to be executed from the project root

For Clean Build with Local and External Dependency Loading: npm run clean:build For Build with Local and External Dependency Loading: npm run load:build For Build Only: npm run build

Development Testing

After a Lerna clean:build navigate to system/dist and run node index.js and append your bake commands including mix --name "my_deployment:latest" --runtime "latest" ./package/test.yaml. All dependencies should be linked through Lerna as long as they have been properly setup and run through the build process.

Install

npm i -g azure-bake

Overview

Bake is an Azure deployment tool & system designed to treat both infrastructure as code and also package built software artifacts alongside that infrastructure. This bundling allows for rapid and agile usage of infrastructure as needed by software changes.

This system is not intended as a replacement for popular/standard pipeline systems for deployment, but instead to work within them as a task runner.

For the moment we have native support for Azure DevOps pipelines (build and deploy) to both generate bake recipes at build time (create pipeline build artifacts) and then deploy those recipes via release pipelines.

We also support bake at the command line via the provided CLI. With that, you can integrate with most popular pipeline products

Recipe & Ingredients

A bake recipe is a YAML document that describes what should be deployed. This is described as a list of bake ingredients.

Bake ingredients are external plugins that provide deployment functionality for a recipe. This includes ingredients that deploy azure ARM templates, or execute custom javascript/typescript, or more managed ingredients that automate the deployment of common resources like storage, cosmosDB, etc. Bake provides a set of ingredients for usage, and 3rd party ingredients can be included as well.

Once you mix a bake recipe a docker image is generated that includes everything needed to deploy your recipe. This docker recipe package is then uploaded into a docker repositry for later deployment. Bake recipe packages are tagged so that different versions can be deployed as needed.

Usage

Mix / Create a deploment recipe

bake mix --name "my_deployment:latest" --runtime "latest" ./package/bake.yaml
  • name : name of the local docker image:tag that will get generated
  • runtime: which version of the bake runtime to build a package against.
    • "latest" will be against the latest runtime version at mix time, once built the version will not change.
    • Check the docker hub for all runtime versions: bake tags

Serve / Deploy a recipe

bake serve "mydocker/myrecipe:0.0.1"

Serve takes in a docker image tag to deploy. This should map to a docker image (local or remote) that was mixed with bake.

Note: There are several environment variables for azure authentication and environment selection that need to be set before you can serve a recipe:

Environment nameDescription
BAKE_AUTH_SUBSCRIPTION_IDAzure subscription ID to deploy recipes into
BAKE_AUTH_SERVICE_IDAzure Service Principle user ID with correct ACLs for your deployment needs
BAKE_AUTH_SERVICE_KEYSecret key for the service principle
BAKE_AUTH_TENANT_IDAzure Active Directory tenant id/name for your deployment service princple
BAKE_ENV_NAMEFull name of the environment this deployment is for
BAKE_ENV_CODE4 letter environment code, used for naming of resources/resource groups
BAKE_ENV_REGIONSJSON array of region objects that the recipe should deploy to
BAKE_VARIABLESJSON of bake variables that the recipe can access
BAKE_LOG_LEVELLog levels include debug, info (default if unspecified), warn, and error

note: read the section on Environment for a deeper explanation of environment/regions/variables

Bake YAML schema

At the core of a recipe is the bake.yaml file which drives the deployment of all included recipes. The schema documentation can be found here

Bake Environment Structure/Terms

Bake uses the concept of an "environment" as a virtual grouping of deployment resources. An environment has to deploy into an Azure subscription, but you can deploy multiple environments into the same subscription.

To setup an environment you must define a few items:

  • BAKE_ENV_NAME: This is the descriptive name of your environment. This is used in logging, tagging, and other areas where allowed.
  • BAKE_ENV_CODE: This is a 4 letter code, and must be unique across all your environments (even subscriptions). Some azure resource names are global, and this code helps generate a unique key for your resource
  • BAKE_ENV_REGIONS: This is a JSON array object of regions structures. Bake requires at least one azure region to deploy, and will deploy into all regions supplied. note: bake deploys resources to regions in parallel by default, but can be turned off per recipe if seqential is required

region structure

{
    "name":"East US",
    "code":"eus",
    "shortName":"eastus"
}
  • Name from: Azure published regions
  • code: 3/4 letter code to describe the region (used for naming resources)
  • shortName: the azure region location identifier for the Azure management API.
    • You can get this from the powershell: Get-AzureRMLocation | Format-Table
# setting regions to both east and west US
set BAKE_ENV_REGIONS='[{"name":"East US","code":"eus","shortName":"eastus"},{"name":"West US","code":"wus","shortName":"westus"}]'
  • BAKE_VARIABLES: JSON of name/value pair variables that the recipe can access. These are typically used as environment wide/specific settings to configure recipes per environment (i.e. enviroment specific secret keys, etc.)

JSON structure

'storage_key': 'secret'
'env_type': 'prod'
set BAKE_VARIABLEs='{ ''storage_key'': ''secret'', ''env_type'':''prod'' }'

Azure resource groups

Within a bake environment each deployed recipe will generate a resource group for the resources within the recipe to deploy. A recipe can turn off resource group deployment, if for instance the recipe contains only deployed software and not infrastructure.

A recipe can also override the resource group it should deploy into, instead of generating a group name based on the env-region-recipe_name. This is a very advanced feature however, and will probably require an expression to build up the name at least based on environment name and possibly region.

Azure infrastructure resources

When bake deploys an azure resource, the name of the resource should be stable so that redeploying the recipe will generate the same resource name. This is true for all bake created ingredients (@azbake/ingredient-*). For resource names to be stable a resource id is generated based on the env_code, region_code, and recipe short name.

How to develop custom ingredients

Custom ingredients can be developed by following this guide, and then publishing them to either an internal or external npm package repository.

Bake supplied Ingredients

@azbake/ingredient-arm

Simple ingredient that allows deploying Azure ARM json templates. Parameters are supplied via native bake ingredient parameters

read more

@azbake/ingredient-script

Simple ingredient that allows executing javascript/typescript functions. Parameters are avalible inside the function, as well as the full bake deployment context. Useful for implementing edge case deployment needs, or stop gap before an external ingredient supports.

read more

@azbake/ingredient-utils

Ingredient provides all core expression methods, and helpers for current bake context, azure resources. For example:

  • Get current region object - useful inside an ingredient param to know current location
  • Create resource name: Generate a proper resource name for the current context (region, subscription, env, etc.)
  • read more

@azbake/ingredient-webapp-container

Ingredient that allows deploying Azure Web Apps for Containers. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-traffic-manager

Ingredient that allows deploying Azure Traffic Manager profile and endpoints for each region. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-host-names

Ingredient that allows deploying custom host names and ssl certificates to Azure Web Sites. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-app-service-plan

Ingredient that allows deploying App Service Plan. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-service-bus-namespace

Ingredient that allows deploying Service Bus Namespace. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-databricks

Ingredient that allows deploying Databricks. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-datafactoryv2

Ingredient that allows deploying Azure Data Factory. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-sql-dwh

Ingredient that allows deploying SQL Data Warehouse. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-sqldb

Ingredient that allows deploying SQL Database. Parameters are supplied via native bake ingredient parameters.

read more

@azbake/ingredient-sqlserver-logical

Ingredient that allows deploying SQL Server Logical. Parameters are supplied via native bake ingredient parameters.

read more

0.1.113

5 months ago

0.1.112

2 years ago

0.1.111

2 years ago

0.1.110

3 years ago

0.1.107

3 years ago

0.1.109

3 years ago

0.1.108

3 years ago

0.1.106

3 years ago

0.1.105

4 years ago

0.1.104

4 years ago

0.1.103

4 years ago

0.1.102

4 years ago

0.1.101

4 years ago

0.1.100

4 years ago

0.1.99

5 years ago

0.1.98

5 years ago

0.1.97

5 years ago

0.1.96

5 years ago

0.1.95

5 years ago

0.1.87

5 years ago

0.1.76

5 years ago

0.1.74

5 years ago

0.1.70

5 years ago

0.1.68

5 years ago

0.1.67

5 years ago

0.1.65

5 years ago

0.1.64

5 years ago

0.1.61

5 years ago

0.1.59

5 years ago

0.1.58

5 years ago

0.1.55

6 years ago

0.1.53

6 years ago

0.1.52

6 years ago

0.1.47

6 years ago

0.1.46

6 years ago

0.1.45

6 years ago

0.1.44

6 years ago

0.1.43

6 years ago

0.1.42

6 years ago

0.1.37

6 years ago

0.1.36

6 years ago

0.1.34

6 years ago

0.1.33

6 years ago

0.1.31

6 years ago

0.1.30

6 years ago

0.1.28

6 years ago

0.1.23

6 years ago

0.1.22

6 years ago

0.0.15

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.11

6 years ago

0.0.10

6 years ago

0.0.9

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago