私はAzuerのファイアウォールルールを作成するために、PowerShellスクリプトを作成しようとしていました。Azureのデフォルトのサブスクリプションが見つからない
私が使用しているコードは次のとおりです。
選択-AzureSubscription:ペイAS-あなた-Goは存在しないサブスクリプション名
$servername = "xxx"
$username = "[email protected]"
$password = "xxx"
$subscription = "Pay-As-You-Go"
$secpasswd = ConvertTo-SecureString
$password -AsPlainText -Force $cred = New-Object System.Management.Automation.PSCredential ($userName, $secpasswd)
Login-AzureRmAccount -Credential $cred -SubscriptionName $subscription
Select-AzureSubscription -SubscriptionName $subscription -Default
$ipAddress = (Invoke-WebRequest 'http://myexternalip.com/raw').Content -replace "`n"
New-AzureSqlDatabaseServerFirewallRule -ServerName $servername -RuleName 'Test' -StartIpAddress $ipAddress -EndIpAddress $ipAddress
は、私はまた、次のエラーを取得します。
と
新AzureSqlDatabaseServerFirewallRule:いいえデフォルトのサブスクリプションが指定されていません。 Select-AzureSubscription -Defaultを使用して、デフォルトの サブスクリプションを設定します。
また、Login-AzureRmAccountをAdd-AzureAccountに変更しようとしましたが、違いはありませんでした。作成したユーザーは、SQLサーバーの所有者です。
他にも何かがありますか?
ああ。私は今、行を追加しました:Get-AzureRMSubscription -SubscriptionName $ subscription | Set-AzureRmContextはGoogleで見つかったが、New-AzureSqlDatabaseServerFirewallRuleはデフォルトのサブスクリプションについて不平を言っている。 –
見つかりました:New-AzureRmSqlServerFirewallRule。リソースグループ名が必要になっただけですが、それは簡単に抽出できました。どうもありがとう –