Powershell脚本检测Azure账号是否登陆,资源组是否创建,并部署ARM template
来源:互联网 发布:淘宝捉猫猫是干什么的 编辑:程序博客网 时间:2024/05/20 16:11
前言:本文提供了一个脚本检测,有如下功能:
1. Azure账户是否已经登陆了,如果没登陆,会提示你登陆。
2. 要创建的资源组是否存在,存在的话不再创建,直接部署template,不存在就先创建资源组,再部署template。
## 简单定义变量$ResourceGroupName='myrsg'$Location='china east'## 检测是否已经登陆azure,如果没登陆,会跳转提示登陆。Try{Get-AzureRmContext -ErrorAction Continue}Catch [System.Management.Automation.PSInvalidOperationException]{Login-AzureRmAccount -EnvironmentName Azurechinacloud}## define the deploy function,指定部署文件的路径。可以是远端文件,也可以是本地文件。Function Deployment([string]$deployPath,[string]$deployParameterPath){ Write-Output "test the deployment" test-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName ` -TemplateFile $deployPath ` -TemplateParameterFile $deployParameterPath Write-Output "deploy begin" New-AzureRmResourceGroupDeployment -ResourceGroupName $ResourceGroupName ` -TemplateFile $deployPath ` -TemplateParameterFile $deployParameterPath}## 检测资源组是否存在,逻辑行为可定制。## reousrceGroup的部署是增量的形式,组下的已有资源不再被重新部署。$resourceGroup = Get-AzureRmResourceGroup -Name $ResourceGroupName -ErrorAction SilentlyContinueif ( -not $ResourceGroup ) { Write-Output "Could not find resource group '$ResourceGroupName' - will create it" Write-Output "Creating resource group '$ResourceGroupName' in location '$Location'" New-AzureRmResourceGroup -Name $resourceGroupName -Location $Location Deployment .\Desktop\template\template\azuredeploy.json .\Desktop\template\template\azuredeploy.parameters.json}else { Write-Output "Using existing resource group '$ResourceGroupName'" Deployment .\Desktop\template\template\azuredeploy.json .\Desktop\template\template\azuredeploy.parameters.json}
阅读全文
0 0
- Powershell脚本检测Azure账号是否登陆,资源组是否创建,并部署ARM template
- 检测是否登陆成功
- [Azure]使用Powershell清理ARM中的无效资源
- Android通过get方法访问Tomcat服务器,发送账号密码,检测登陆是否成功。
- php循环检测目录是否存在并创建
- sql server2005 检测是否原有数据库,并创建
- [Azure]使用Powershell统计ARM存储账号下容器中Blob的使用情况
- [Azure]使用Azure Powershell输出ARM模式下某个账号中所有订阅下的虚拟网络拓扑
- 检测用户是否登陆的过滤器
- 检测用户是否登陆的拦截器
- Swift3检测应用是否为首次登陆
- [Azure] 使用Azure Powershell脚本查看账号下所有订阅中的云服务公网IP地址绑定情况
- 在PowerShell中如何检测模块是否存在
- 使用Azure powershell 创建Azure虚拟机
- iOS - 正则表达式登陆账号、邮箱、身份证..是否正确
- 判断用户是否在线及实现一个账号一个人登陆
- [Azure]使用Powershell删除ARM模式下单台虚拟机及相关资源(非托管磁盘)
- [Azure]使用Powershell删除ARM模式下单台虚拟机及相关资源(托管磁盘)
- 文章标题
- freemarker详解
- ORACLE 创建作业JOB例子
- 物联网技术在农业领域的应用
- 使用Mock MVC来进行Controller 层的junit的测试
- Powershell脚本检测Azure账号是否登陆,资源组是否创建,并部署ARM template
- 项目失败了?!怎么补救才能不被裁?
- Vue
- Codeforces 340C Tourist Problem【思维】
- 被同事要求帮修电脑时怎么拒绝最好?
- sqlserver导出CVS文件换行
- LeetCode: 463. Island Perimeter
- BP算法公式推导
- Docker 快速入门指引及相关概念知识概览