Skip to content

Commit

Permalink
ARM-based DevOps tools. (#1031)
Browse files Browse the repository at this point in the history
  • Loading branch information
azaslonov authored Nov 14, 2020
1 parent 8d1f78f commit d930068
Show file tree
Hide file tree
Showing 17 changed files with 675 additions and 0 deletions.
7 changes: 7 additions & 0 deletions scripts.v3/capture.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@REM Capture the content (incl. pages, media files, configuration, etc.) of API Management developer portal into ./dist/snapshot folder.
@REM @REM Make sure you're logged-in with `az login` command before running the script.

node ./capture ^
--subscriptionId "< your subscription ID >" ^
--resourceGroupName "< your resource group name >" ^
--serviceName "< your service name >"
71 changes: 71 additions & 0 deletions scripts.v3/capture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/**
* This script automates capturing the content of API Management developer portals into snapshot.
* In order to run it, you need to:
*
* 1) Clone the api-management-developer-portal repository:
* git clone https://github.com/Azure/api-management-developer-portal.git
*
* 2) Install NPM packages:
* npm install
*
* 3) Run this script with a valid combination of arguments:
* node ./capture ^
* --sourceSubscriptionId "< your subscription ID >" ^
* --sourceResourceGroupName "< your resource group name >" ^
* --sourceServiceName "< your service name >" ^
* --destSubscriptionId "< your subscription ID >" ^
* --destResourceGroupName "< your resource group name >" ^
* --destServiceName "< your service name >"
*/

const { ImporterExporter } = require("./utils");

const yargs = require('yargs')
.example(`node ./capture ^ \r
--subscriptionId "< your subscription ID >" ^ \r
--resourceGroupName "< your resource group name >" ^ \r
--serviceName "< your service name >"\n`)
.option('subscriptionId', {
type: 'string',
description: 'Azure subscription ID.',
demandOption: true
})
.option('resourceGroupName', {
type: 'string',
description: 'Azure resource group name.',
demandOption: true
})
.option('serviceName', {
type: 'string',
description: 'API Management service name.',
demandOption: true
})
.help()
.argv;

async function capture() {
const importerExporter = new ImporterExporter(
yargs.subscriptionId,
yargs.resourceGroupName,
yargs.serviceName
);

await importerExporter.export();

console.log(`The content captured in "./dist/snapshot" folder.`);
}

capture()
.then(() => {
console.log("DONE");
process.exit(0);
})
.catch(error => {
console.error(error);
process.exit(1);
});


module.exports = {
capture
}
7 changes: 7 additions & 0 deletions scripts.v3/cleanup.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@REM Delete the content (incl. pages, media files, configuration, etc.) of API Management developer portal.
@REM Make sure you're logged-in with `az login` command before running the script.

node ./cleanup ^
--subscriptionId "< your subscription ID >" ^
--resourceGroupName "< your resource group name >" ^
--serviceName "< your service name >"
67 changes: 67 additions & 0 deletions scripts.v3/cleanup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* This script automates deleting the content of API Management developer portals.
* In order to run it, you need to:
*
* 1) Clone the api-management-developer-portal repository:
* git clone https://github.com/Azure/api-management-developer-portal.git
*
* 2) Install NPM packages:
* npm install
*
* 3) Run this script with a valid combination of arguments:
* node ./cleanup ^
* --sourceSubscriptionId "< your subscription ID >" ^
* --sourceResourceGroupName "< your resource group name >" ^
* --sourceServiceName "< your service name >" ^
* --destSubscriptionId "< your subscription ID >" ^
* --destResourceGroupName "< your resource group name >" ^
* --destServiceName "< your service name >"
*/

const { ImporterExporter } = require("./utils");

const yargs = require('yargs')
.example(`node ./cleanup ^ \r
--subscriptionId "< your subscription ID >" ^ \r
--resourceGroupName "< your resource group name >" ^ \r
--serviceName "< your service name >"\n`)
.option('subscriptionId', {
type: 'string',
description: 'Azure subscription ID.',
example: '<bla bla>',
demandOption: true
})
.option('resourceGroupName', {
type: 'string',
description: 'Azure resource group name.'
})
.option('serviceName', {
type: 'string',
description: 'API Management service name.',
})
.help()
.argv;

async function cleanup() {
const importerExporter = new ImporterExporter(
yargs.subscriptionId,
yargs.resourceGroupName,
yargs.serviceName
);

await importerExporter.cleanup();
}

cleanup()
.then(() => {
console.log("DONE");
process.exit(0);
})
.catch(error => {
console.error(error);
process.exit(1);
});

module.exports = {
cleanup
}
1 change: 1 addition & 0 deletions scripts.v3/data.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions scripts.v3/generate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@REM Generate content (incl. pages, media files, configuration, etc.) of API Management developer portal from ./dist/snapshot folder.
@REM Make sure you're logged-in with `az login` command before running the script.

node ./generate ^
--subscriptionId "< your subscription ID >" ^
--resourceGroupName "< your resource group name >" ^
--serviceName "< your service name >"
69 changes: 69 additions & 0 deletions scripts.v3/generate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* This script automates generating the content of API Management developer portals from the snapshot.
* In order to run it, you need to:
*
* 1) Clone the api-management-developer-portal repository:
* git clone https://github.com/Azure/api-management-developer-portal.git
*
* 2) Install NPM packages:
* npm install
*
* 3) Run this script with a valid combination of arguments:
* node ./cleanup ^
* --sourceSubscriptionId "< your subscription ID >" ^
* --sourceResourceGroupName "< your resource group name >" ^
* --sourceServiceName "< your service name >" ^
* --destSubscriptionId "< your subscription ID >" ^
* --destResourceGroupName "< your resource group name >" ^
* --destServiceName "< your service name >"
*/

const { ImporterExporter } = require("./utils");

const yargs = require('yargs')
.example(`node ./generate ^ \r
--subscriptionId "< your subscription ID >" ^ \r
--resourceGroupName "< your resource group name >" ^ \r
--serviceName "< your service name >"\n`)
.option('subscriptionId', {
type: 'string',
description: 'Azure subscription ID.',
demandOption: true
})
.option('resourceGroupName', {
type: 'string',
description: 'Azure resource group name.',
demandOption: true
})
.option('serviceName', {
type: 'string',
description: 'API Management service name.',
demandOption: true
})
.help()
.argv;

async function generate() {
const importerExporter = new ImporterExporter(
yargs.subscriptionId,
yargs.resourceGroupName,
yargs.serviceName
);

await importerExporter.import();
}

generate()
.then(() => {
console.log("DONE");
process.exit(0);
})
.catch(error => {
console.error(error);
process.exit(1);
});


module.exports = {
generate
}
7 changes: 7 additions & 0 deletions scripts.v3/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Generate and provision default content of an API Management portal - incl. pages, layouts, configuration, media files, etc.
# Make sure you're logged-in with `az login` command before running the script.

node ./generate \
--subscriptionId "< your subscription ID >" \
--resourceGroupName "< your resource group name >" \
--serviceName "< your service name >"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions scripts.v3/migrate.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@REM This script automates content migration between developer portal instances.
@REM Make sure you're logged-in with `az login` command before running the script.

node ./migrate ^
--sourceSubscriptionId "< your subscription ID >" ^
--sourceResourceGroupName "< your resource group name >" ^
--sourceServiceName "< your service name >" ^
--destSubscriptionId "< your subscription ID >" ^
--destResourceGroupName "< your resource group name >" ^
--destServiceName "< your service name >"
90 changes: 90 additions & 0 deletions scripts.v3/migrate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
* This script automates deployments between developer portal instances.
* In order to run it, you need to:
*
* 1) Clone the api-management-developer-portal repository:
* git clone https://github.com/Azure/api-management-developer-portal.git
*
* 2) Install NPM packages:
* npm install
*
* 3) Run this script with a valid combination of arguments:
* node ./migrate ^
* --sourceSubscriptionId "< your subscription ID >" ^
* --sourceResourceGroupName "< your resource group name >" ^
* --sourceServiceName "< your service name >" ^
* --destSubscriptionId "< your subscription ID >" ^
* --destResourceGroupName "< your resource group name >" ^
* --destServiceName "< your service name >"
*
* Auto-publishing is not supported for self-hosted versions, so make sure you publish the portal (for example, locally)
* and upload the generated static files to your hosting after the migration is completed.
*
* You can specify the SAS tokens directly (via sourceToken and destToken), or you can supply an identifier and key,
* and the script will generate tokens that expire in 1 hour. (via sourceId, sourceKey, destId, destKey)
*/

const { ImporterExporter } = require('./utils.js');

const yargs = require('yargs')
.example(`node ./migrate ^ \r
--sourceSubscriptionId "< your subscription ID > ^ \r
--sourceResourceGroupName "< your resource group name >" ^ \r
--sourceServiceName "< your service name >" ^ \r
--destSubscriptionId "< your subscription ID >" ^ \r
--destResourceGroupName "< your resource group name >" ^ \r
--destServiceName "< your service name >"\n`)
.option('sourceSubscriptionId', {
type: 'string',
description: 'Azure subscription ID.',
demandOption: true
})
.option('sourceResourceGroupName', {
type: 'string',
description: 'Azure resource group name.',
demandOption: true
})
.option('sourceServiceName', {
type: 'string',
description: 'API Management service name.',
demandOption: true
})
.option('destSubscriptionId', {
type: 'string',
description: 'Azure subscription ID.',
demandOption: true
})
.option('destResourceGroupName', {
type: 'string',
description: 'Azure resource group name.',
demandOption: true
})
.option('destServiceName', {
type: 'string',
description: 'API Management service name.',
demandOption: true
})
.help()
.argv;

async function migrate() {
const sourceImporterExporter = new ImporterExporter(yargs.sourceSubscriptionId, yargs.sourceResourceGroupName, yargs.sourceServiceName);
await sourceImporterExporter.export();

const destIimporterExporter = new ImporterExporter(yargs.destSubscriptionId, yargs.destResourceGroupName, yargs.destServiceName);
await destIimporterExporter.cleanup();
await destIimporterExporter.import();

/* New publishing endpoint is not deployed to production yet. */
// await destIimporterExporter.publish();
}

migrate()
.then(() => {
console.log("DONE");
process.exit(0);
})
.catch(error => {
console.error(error);
process.exit(1);
});
Loading

0 comments on commit d930068

Please sign in to comment.