设为首页 收藏本站
查看: 701|回复: 0

[经验分享] 用Json Template在Azure上创建Cisco CSR路由器

[复制链接]

尚未签到

发表于 2017-6-30 13:08:10 | 显示全部楼层 |阅读模式
  Azure的ARM模式可以通过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虚拟机
  1. 登录Azure China的Portal
  2. 在New中搜索template
DSC0000.png

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

  把刚刚的Json Template上传。
  4. 填写相应的Parameters
DSC0002.png

  根据实际值,填写相应的参数。需要注意的是Resource Group和Storage Account都要和image所在的Storage Account相同。
  4. Legal Terms
  把Legal Terms相应的内容填写完整:
DSC0003.png

  然后点击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
......

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-389660-1-1.html 上篇帖子: 如何用Azure Web App Services接入微信公众号 下篇帖子: Writing DynamicTableEntity to Azure Storage Table
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表