用 Json Template 在 Azure 上创建 Cisco CSR 路由器

魏衡,微软云资深架构师,国内Azure最早的架构师之一

Azure的ARM(Azure资源管理器)模式可以通过Json的模板创建VM(虚拟机)。本文以Cisco的CSR的image为例,介绍如何用Json创建VM。

一、Cisco CSR的Image

首先把Cisco CSR的image复制到一个存储账户中:

https://xxxx.blob.core.chinacloudapi.cn/image/CSR_3_16_4aS_CCO.vhd

创建VM的vhd文件也需要在这个存储账户中。

二、获得Json模板

在Github上找到From user image create VM的Json模板:

https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-from-user-image

把azuredeploy.json文件保存到本地:

https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-vm-from-user-image/azuredeploy.json

为d:\from_image.json文件。由于Global Azure的Disk目前已经prefer使用Management Disk了,Github上的template已经改成MD的template。

下面是采用普通存储账户的Json Template:

{

"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",

"contentVersion": "1.0.0.0",

"parameters": {

"customVmName": {

"type": "string",

"metadata": {

"description": "This is the name of the your VM"

}

},

"userImageStorageAccountName": {

"type": "string",

"metadata": {

"description": "This is the name of the your storage account"

}

},

"userImageStorageAccountResourceGroupName": {

"type": "string",

"metadata": {

"description": "Resource group of the existing storage account"

}

},

"osDiskVhdUri": {

"type": "string",

"metadata": {

"description": "Uri of the your user image"

}

},

"dnsLabelPrefix": {

"type": "string",

"metadata": {

"description": "DNS Label for the Public IP. Must be lowercase. It should match with the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$ or it will raise an error."

}

},

"adminUserName": {

"type": "string",

"metadata": {

"description": "User Name for the Virtual Machine"

}

},

"adminPassword": {

"type": "securestring",

"metadata": {

"description": "Password for the Virtual Machine"

}

},

"osType": {

"type": "string",

"allowedValues": [

"Windows",

"Linux"

],

"metadata": {

"description": "This is the OS that your VM will be running"

}

},

"vmSize": {

"type": "string",

"metadata": {

"description": "This is the size of your VM"

}

},

"newOrExistingVnet": {

"allowedValues": [ "new", "existing" ],

"type": "string",

"metadata": {

"description":  "Select if this template needs a new VNet or will reference an existing VNet"

}

},

"newOrExistingVnetName": {

"type": "string",

"defaultValue": "",

"metadata": {

"description": "New or Existing VNet Name"

}

},

"newOrExistingSubnetName": {

"type": "string",

"metadata": {

"description": "New or Existing subnet Name"

}

},

"existingVnetResourceGroupName": {

"type": "string",

"metadata": {

"description": "Resource group of the existing VNET"

}

}

},

"variables": {

"publicIPAddressName": "[concat(parameters('customVmName'),'IP')]",

"vmName": "[parameters('customVmName')]",

"nicName": "[concat(parameters('customVmName'),'Nic')]",

"publicIPAddressType": "Dynamic",

"apiVersion": "2015-06-15",

"templatelink": "[concat('https://raw.githubusercontent.com/singhkay/azure-quickstart-templates/master/101-vm-from-user-image/',parameters('newOrExistingVnet'),'vnet.json')]"

},

"resources": [

{

"apiVersion": "2015-01-01",

"name": "vnet-template",

"type": "Microsoft.Resources/deployments",

"properties": {

"mode": "incremental",

"templateLink": {

"uri": "[variables('templatelink')]",

"contentVersion": "1.0.0.0"

},

"parameters": {

"virtualNetworkName": {

"value": "[parameters('newOrExistingVnetName')]"

},

"subnetName": {

"value": "[parameters('newOrExistingSubnetName')]"

},

"existingVnetResourceGroupName": {

"value": "[parameters('existingVnetResourceGroupName')]"

}

}

}

},

{

"apiVersion": "[variables('apiVersion')]",

"type": "Microsoft.Network/publicIPAddresses",

"name": "[variables('publicIPAddressName')]",

"location": "[resourceGroup().location]",

"properties": {

"publicIPAllocationMethod": "[variables('publicIPAddressType')]",

"dnsSettings": {

"domainNameLabel": "[parameters('dnsLabelPrefix')]"

}

}

},

{

"apiVersion": "2016-03-30",

"type": "Microsoft.Network/networkInterfaces",

"name": "[variables('nicName')]",

"location": "[resourceGroup().location]",

"dependsOn": [

"[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",

"Microsoft.Resources/deployments/vnet-template"

],

"properties": {

"ipConfigurations": [

{

"name": "ipconfig1",

"properties": {

"privateIPAllocationMethod": "Dynamic",

"publicIPAddress": {

"id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"

},

"subnet": {

"id": "[reference('vnet-template').outputs.subnet1Ref.value]"

}

}

}

]

}

},

{

"apiVersion": "[variables('apiVersion')]",

"type": "Microsoft.Compute/virtualMachines",

"name": "[variables('vmName')]",

"location": "[resourceGroup().location]",

"dependsOn": [

"[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"

],

"properties": {

"hardwareProfile": {

"vmSize": "[parameters('vmSize')]"

},

"osProfile": {

"computerName": "[variables('vmName')]",

"adminUsername": "[parameters('adminUsername')]",

"adminPassword": "[parameters('adminPassword')]"

},

"storageProfile": {

"osDisk": {

"name": "[concat(variables('vmName'),'-osDisk')]",

"osType": "[parameters('osType')]",

"caching": "ReadWrite",

"createOption": "FromImage",

"image": {

"uri": "[parameters('osDiskVhdUri')]"

},

"vhd": {

"uri": "[concat(reference(resourceId(parameters('userImageStorageAccountResourceGroupName'), 'Microsoft.Storage/storageAccounts/', parameters('userImageStorageAccountName')), variables('apiVersion')).primaryEndpoints.blob, 'vhds/',variables('vmName'), uniquestring(resourceGroup().id), 'osDisk.vhd')]"

}

}

},

"networkProfile": {

"networkInterfaces": [

{

"id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"

}

]

},

"diagnosticsProfile": {

"bootDiagnostics": {

"enabled": "true",

"storageUri": "[concat(reference(resourceId(parameters('userImageStorageAccountResourceGroupName'), 'Microsoft.Storage/storageAccounts/', parameters('userImageStorageAccountName')), variables('apiVersion')).primaryEndpoints.blob)]"

}

}

}

}

]

}

三、通过模板创建Cisco CSR虚拟机

登录Azure 门户;

在New中搜索template;



如上图所示,点击Template Deployment。这里需要注意的是,目前必须是英文版本才可以使用这个功能。

导入template;



把刚刚的Json Template上传。

填写相应的Parameters;



根据实际值,填写相应的参数。需要注意的是Resource Group和Storage Account都要和image所在的Storage Account相同。

Legal Terms;

把Legal Terms相应的内容填写完整:



然后点击create,创建VM。

四、登录创建的Cisco CSR router;

Connecting to 42.159.203.233:22...

Connection established.

To escape to local shell, press Ctrl+Alt+].

hengweicisco#sh runn

Building configuration...

Current configuration : 1294 bytes

!

! Last configuration change at 10:21:56 UTC Mon Apr 24 2017

!

version 15.5

service timestamps debug datetime msec

service timestamps log datetime msec

no platform punt-keepalive disable-kernel-core

platform console virtual

!

hostname hengweicisco

!

boot-start-marker

boot-end-marker

!

logging persistent size 1000000 filesize 8192 immediate

!

aaa new-model

!

aaa authentication login default local

aaa authorization exec default local none

!

aaa session-id common

光看云社区未使用 Azure?

申请试用

标签

公告 (159)

虚拟机 (70)

解决方案 (69)

云服务 (62)

存储 (57)

网站 (53)

常见问题 (50)

SQL 数据库 (45)

Windows Azure 开源解决方案 (25)

服务总线 (24)

Active Directory (24)

媒体服务 (18)

虚拟网络 (12)

移动服务 (12)

HDInsight (11)

备份 (9)

Azure (7)

网络服务 (7)

站点恢复 (7)

CDN (6)

流量管理器 (6)

MySQL Database on Azure (4)

VPN (2)

blob (2)

DocumentDB (2)

Azure VMSS (2)

Microsoft R Server (2)

SQL (2)

ARM (2)

Azure SQL (2)

数据库 (2)

物联网 (2)

FreeBSD (2)

计费 (2)

Azure 分析服务 (1)

Azure SQL DataBase (1)

SQL Server (1)

数据科学虚拟机镜像 (1)

Visual Studio 2017 虚拟机镜像 (1)

SQL 2017,Azure SQL (1)

共享目录 (1)

SQL On Linux (1)

SQL2016,security (1)

数据库权限,分配 (1)

NSC (1)

Ubuntu Docker,SQL Server (1)

BGP (1)

Azure Linux Disk (1)

Powershell (1)

cache (1)

Json Template (1)

Cisco CSR (1)

Azure ARM (1)

VNet (1)

Storm (1)

HBASE (1)

事件中心 (1)

流处理 (1)

Storm,HBASE,事件中心,流处理 (1)

Azure Python SDK (1)

Azure IoT 中心服务,根证书 (1)

Azure Cosmos DB (1)

VMSS (1)

Microsoft R Server (1)

事件中心捕获 (1)

performance optimization (1)

自定义镜像 (1)

private disk (1)

Vnet (1)

OnPrem (1)

logic server (1)

Infrastructure (1)

auto deployment (1)

站点,访问,实践 (1)

Azure Portal (1)

Azure Resource Template (1)

private storage (1)

AAD (1)

ACS (1)

迁移 (1)

兼容性 (1)

SQL数据库 (1)

AzureSQL (1)

初级 (1)

Visual Studio (1)

SQL Server (1)

PaaS (1)

HTTPS自有证书 (1)

域名管理 (1)

证书部署 (1)

云计算 (1)

AzureStorage (1)

azure-availability (1)

azure-networking1 (1)

IoT 中心 (1)

IoT Suite (1)

VM (1)

CDN Smart Routing (1)

BSD (1)

AppleTV (1)

Apple FairPlay (1)

Azure Stack (1)

Azure云助手 (1)

Cloud Foundry (1)

虚拟机 (1)

PowerShell (1)

移动终端 (1)

服务仪表盘 (1)

立即访问http://market.azure.cn

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 158,736评论 4 362
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 67,167评论 1 291
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 108,442评论 0 243
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 43,902评论 0 204
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 52,302评论 3 287
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 40,573评论 1 216
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 31,847评论 2 312
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 30,562评论 0 197
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 34,260评论 1 241
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 30,531评论 2 245
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 32,021评论 1 258
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 28,367评论 2 253
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 33,016评论 3 235
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 26,068评论 0 8
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 26,827评论 0 194
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 35,610评论 2 274
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 35,514评论 2 269

推荐阅读更多精彩内容