Skip to content

Commit

Permalink
fix: Adds 3 ingredients for web apps (webapp, traffic manager, custom…
Browse files Browse the repository at this point in the history
… hostnames with ssl), teaches core-utils how to recognize a primary region, and cleans up boilerplate code for deploying arm templates through ingredients into a helper package.
  • Loading branch information
JasonPagel authored and whilke committed Feb 12, 2019
1 parent 57f8e29 commit 0304458
Show file tree
Hide file tree
Showing 51 changed files with 4,033 additions and 1,746 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
* [@azbake/ingredient-arm](./ingredient/ingredient-arm/CHANGELOG.md)
* [@azbake/ingredient-script](./ingredient/ingredient-script/CHANGELOG.md)
* [@azbake/ingredient-utils](./ingredient/ingredient-utils/CHANGELOG.md)
* [@azbake/ingredient-webapp-container](./ingredient/ingredient-webapp-container/CHANGELOG.md)
* [@azbake/ingredient-traffic-manager](./ingredient/ingredient-traffic-manager/CHANGELOG.md)
* [@azbake/ingredient-host-names](./ingredient/ingredient-host-names/CHANGELOG.md)

## Install
```
Expand Down Expand Up @@ -133,3 +136,17 @@ Ingredient provides all core expression methods, and helpers for current bake co
* Create resource name: Generate a proper resource name for the current context (region, subscription, env, etc.)
* [read more](./ingredient/ingredient-arm/README.md)

### @azbake/ingredient-webapp-container
Ingredient that allows deploying Azure Web Apps for Containers. Parameters are supplied via native bake ingredient parameters.

[read more](./ingredient/ingredient-webapp-container/README.md)

### @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](./ingredient/ingredient-traffic-manager/README.md)

### @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](./ingredient/ingredient-host-names/README.md)
6 changes: 6 additions & 0 deletions arm-helper/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
src/
.vscode/
package/
test/
*.tgz
tsconfig.json
4 changes: 4 additions & 0 deletions arm-helper/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Change Log

All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
110 changes: 110 additions & 0 deletions arm-helper/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
## Changelogs
* [@azbake/arm-helper](./CHANGELOG.md)

## Overview

ARM Helper is a utility plugin for Bake that can be used by ingredients to easily deploy ARM templates.

## Usage

To use, install the utility as a dependency for your ingredient.

```bash
npm i @azbake/arm-helper
```

## ARMHelper class

Class for deploying ARM templates and transforming bake parameters into ARM template parameters.

### Constructors

ARMHelper(context)

### Functions

|function|description|
|--------|-----------|
|DeployTemplate(deploymentName, template, params, resourceGroup)| Deploys the specified ARM template with the specified parameters.|
|BakeParamsToARMParams(deploymentName, params)| Converts bake parameters to the format expected by ARM for ARM parameters.|

### Constructor Details

#### ARMHelper(context)

```typescript
new ARMHelper(context)
```

##### Parameters
|parameter|type|required|description|
|---------|----|--------|-----------|
|``context``|DeploymentContext|yes|The current bake deployment context|

### Function Details

#### DeployTemplate(deploymentName, template, params, resourceGroup)

Deploys the specified ARM template with the specified parameters to the specified resourceGroup. This is a long running function and should be used with the ``await`` operator.

```typescript
public async DeployTemplate(deploymentName, template, params, resourceGroup)
```

##### Parameters
|parameter|type|required|description|
|---------|----|--------|-----------|
|``deploymentName``|string|yes|Name of the deployment for Azure.|
|``template``|any|yes|JSON object representing the arm template|
|``params``|any|yes|JSON object representing parameters used in the ARM template|
|``resourceGroup``|string|yes|Name of the resource group the ARM template will deploy into|

##### Returns
``Promise<void>``

#### BakeParamsToARMParams(deploymentName, params)

Reads the Bake parameters and converts them into values acceptable for parameters of ARM templates.

```typescript
public BakeParamsToARMParams(deploymentName, params)
```

##### Parameters
|parameter|type|required|description|
|---------|----|--------|-----------|
|``deploymentName``|string|yes|Name of the azure deployment|
|``params``|``Map<string, BakeVariable>``|yes|The parameters passed into the ingredient|

##### Returns
``any``

JSON object of parameters to load into the ARM template during deployment.







## Example

```typescript
import { BaseIngredient, IngredientManager } from "@azbake/core"
import { ARMHelper } from "@azbake/arm-helper"
import arm from "./arm.json"

export class MyIngredient extends BaseIngredient {

public async Execute(): Promise<void> {

const util = IngredientManager.getIngredientFunction("coreutils", this._ctx)
const helper = new ARMHelper(this._ctx)

const parameters = helper.BakeParamsToARMParams(this._name, this._ingredient.properties.parameters)

await helper.DeployTemplate(this._name, arm, parameters, util.resource_group())
}
}

```
184 changes: 184 additions & 0 deletions arm-helper/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions arm-helper/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"name": "@azbake/arm-helper",
"description": "Helper class for installing ARM templates through Bake.",
"version": "0.0.1",
"main": "dist/arm-helper.js",
"author": "HCHB",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/HomecareHomebase/azure-bake.git"
},
"bugs": {
"url": "https://github.com/HomecareHomebase/azure-bake/issues"
},
"homepage": "https://github.com/HomecareHomebase/azure-bake",
"scripts": {
"upload": "tsc -p ./src && npm --no-git-tag-version version patch && npm publish --access public",
"compile": "tsc",
"watch": "tsc -w -p ./src"
},
"peerDependencies": {
"@azbake/core": "0.*",
"@azure/arm-resources": "^1.0.1"
},
"devDependencies": {
"@types/node": "^10.12.18"
},
"dependencies": {
"@azure/arm-resources": "^1.0.0"
},
"publishConfig": {
"access": "public"
}
}
Loading

0 comments on commit 0304458

Please sign in to comment.