Giter Site home page Giter Site logo

khilscher / azure-arm-validator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from azure/azure-arm-validator

0.0 2.0 0.0 59 KB

A tiny server which will validate Azure Resource Manager scripts

JavaScript 96.77% Shell 2.07% CSS 0.33% HTML 0.83%

azure-arm-validator's Introduction

azure-arm-validator

Build Status Code Climate

A tiny server which will validate Azure Resource Manager scripts.

What does it Do?

You probably won't need this server. It's a glorified wrapper around the azure-cli but is used by the Azure Quickstart Templates project for automated template deployments.

Endpoints

The server has two simple endpoints /validate and /deploy.

POST - /validate

Body:

{
  "template": { 
  },
  "parameters": {
  },
  "pull_request": 44
}

Response:

Upon success you will recieve:

Status: 200

{ "result": "Template Valid" }

Upon failure you will recieve:

{ "result": "[azure cli error message]", "command": "[the cli command used]", "template": "[the exact template file contents used]", "parameters": "[the exact template paramters provided]"}

POST - /deploy

The deploy endpoint interface is the same as /validate except it will deploy the template. It will keep the HTTP connection as long as required to deploy the template, but will always respond with a 202 'Accepted' status, regardless of the outcome. It is the responsibility of the client to inspect the response body for sucess, or failure.

Body:

{
  "template": { 
  },
  "parameters": {
  },
  "pull_request": 44
}

Response:

Upon success you will recieve:

Status: 202

{ "result": "Deployment Successful" }

Upon failure you will recieve:

{ "result": "[azure cli error message]", "command": "[the cli command used]", "template": "[the exact template file contents used]", "parameters": "[the exact template parameters provided]"}

Parameters File Special Values

The server by default configuration will replace several special value type fields in the parameters file:

  • GEN-UNIQUE - Replaces this with a generated unique value suitable for domain names, storage accounts and usernames. The length of the generated paramter will be 18 characters long.
  • GEN-UNIQUE-[N] - Replaces this with a generated unique value suitable for domain names, sotrage accounts and usernames. The length is specified by [N] where it can be any number between 3 to 32 inclusive. For example, GEN_UNIQUE_22.
  • GEN-PASSWORD - Replaces this with a generated azure-compatible password, useful for virtual machine names.
  • GEN-SSH-PUB-KEY - Replaces this with a generated SSH public key

In a typical azuredeploy.parameters.json your template file would look like:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "newStorageAccountName":{
      "value": "GEN_UNIQUE"
    },
    "location": {
      "value": "West US"
    },
    "adminUsername": {
      "value": "sedouard"
    },
    "sshKeyData": {
      "value": "GEN_SSH_PUB_KEY"
    },
    "dnsNameForPublicIP": {
      "value": "GEN_UNIQUE"
    }
  }
}

Running the Server

There are a couple things to do before you can run the server.

Configuration

A configuration file example is provided at ./.example-config.json:

{
  "comment": "You can either set these values as environment variables or to a file called '.config.json' at the root of the repo",
  "AZURE_CLIENT_ID": "00000000-0000-0000-0000-000000000000",
  "AZURE_TENANT_ID": "00000000-0000-0000-0000-000000000000",
  "AZURE_CLIENT_SECRET": "00000000-0000-0000-0000-000000000000",
  "AZURE_REGION": "westus",
  "TEST_RESOURCE_GROUP_NAME": "azure_test_rg",
  "RESOURCE_GROUP_NAME_PREFIX": "qstci-",
  "MONGO_URL": "mongodb://localhost:27017/arm-validator",
  "PARAM_REPLACE_INDICATOR": "GEN_UNIQUE",
  "SSH_KEY_REPLACE_INDICATOR": "GEN_SSH_PUB_KEY",
  "SSH_PUBLIC_KEY": "ssh-rsa create an ssh public key using ssh-keygen",
  "PASSWORD_REPLACE_INDICATOR": "GEN_PASSWORD",
  "GITHUB_REPO": "Azure/azure-quickstart-templates"
}

You can set any of these values as environment variables, or placing it in a file called .config.json at the root of this repo making it easy to deploy.

Mongodb

The server uses MongoDB to record created resource groups to persistenence. On restart, it will attempt to delete any resource group listed in the database. This helps ensure the unlikely possibility of a resource group hanging around after a template deployment. Be sure to set MONGO_URL to an accessible MongoDB instance.

Service Prinicpal

You'll also need to setup a service principal for the server to access your azure subscription.

Contributing

See the contributing guide file for details on how to contribute.

azure-arm-validator's People

Contributors

singhkays avatar

Watchers

James Cloos avatar Kevin Hilscher 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.