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

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

主站蜘蛛池模板: 东辽县| 永安市| 迁西县| 惠来县| 西安市| 岚皋县| 九寨沟县| 绿春县| 施秉县| 神木县| 德州市| 兴安盟| 南岸区| 蒲江县| 济南市| 海安县| 汶上县| 张北县| 临清市| 平罗县| 十堰市| 凤翔县| 吉林市| 汕尾市| 嫩江县| 黔西县| 新营市| 木兰县| 九龙坡区| 洛浦县| 山西省| 任丘市| 临江市| 方正县| 城步| 措美县| 彭阳县| 乐昌市| 东乡县| 沛县| 元江|