官术网_书友最值得收藏!

Deploy-AzureResourceGroup.ps1

In this PowerShell script, we are going to check to see if you are logged in. If you are not logged in, the script will run a validation on your script, create a storage area, upload files to the storage, assign a 4-hour access key, and then run the deployment. The majority of PowerShell is generated when you select an Azure Resource Manager in Visual Studio, but I did add the following login function to help ensure that I am logged in to the right tenant:

function Check-Login
{
$needLogin = $true
Try
{
$content = Get-AzureRmContext
if ($content)
{
$needLogin = ([string]::IsNullOrEmpty($content.Account))
}
}
Catch
{
if ($_ -like "*Login-AzureRmAccount to login*")
{
$needLogin = $true
}
else
{
throw
}
}
if ($needLogin)
{
Login-AzureRmAccount
}
}
Check-Login

主站蜘蛛池模板: 科技| 遵义县| 通化市| 方山县| 邵阳市| 西和县| 富锦市| 永定县| 庄浪县| 杭锦旗| 黑河市| 宁武县| 自治县| 麦盖提县| 永清县| 阿鲁科尔沁旗| 岚皋县| 共和县| 堆龙德庆县| 前郭尔| 普陀区| 永吉县| 阳朔县| 海阳市| 丰县| 顺义区| 望谟县| 祁阳县| 绥芬河市| 庆阳市| 宣城市| 治多县| 萍乡市| 临泽县| 新余市| 嵩明县| 嘉定区| 渝中区| 监利县| 城步| 临沂市|