-2

デプロイ パイプラインの一部として、powershell スクリプトの既存のプロファイルに新しい Traffic Manager エンドポイントを追加しようとしています。Azure portal では、2 番目のエンドポイントを追加するだけで、新しい優先度が割り当てられます。私は加重ポリシーを使用しているため、優先度は私にとって無意味なので、それが何であるかは気にしません。それでもジョブが失敗する可能性があるため、乱数で設定したくありません。

ドキュメントでは、新しいエンドポイントには新しい値が自動的に割り当てられる必要があると主張していますが、これは、最初に既存のエンドポイントをすべて削除してから、それらをすべて追加し直した場合にのみ機能します。すべてのエンドポイント名がわからないので、それらを削除して再度追加する方法がありません。

私はこれに間違って近づいていますか?バグですか?コマンドの使い方が間違っていますか?

エラー テキストは、「Set-AzureRmTrafficManagerProfile : BadRequest: エンドポイントの優先度が正しく設定されていません。すべてのエンドポイントで優先度を設定する必要があります。または、エンドポイントのいずれにも設定しないでください。」

このコードは機能します:

$TrafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name "TMName" -ResourceGroupName "TMRGName"
$publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App1RGName"
Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App1" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
$publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App2RGName"
Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App2" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $TrafficManagerProfile

このコードは失敗します:

   $TrafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name "TMName" -ResourceGroupName "TMRGName"
    $publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App1RGName"
    Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App1" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
    Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $TrafficManagerProfile
    $TrafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name "TMName" -ResourceGroupName "TMRGName"
    $publicIPObj = Get-AzureRmPublicIpAddress -ResourceGroupName "App2RGName"
    Add-AzureRmTrafficManagerEndpointConfig -EndpointName "App2" -EndpointStatus Enabled -TargetResourceId $publicIPObj.id -TrafficManagerProfile $TrafficManagerProfile -Type AzureEndpoints -Weight 10
    Set-AzureRmTrafficManagerProfile -TrafficManagerProfile $TrafficManagerProfile
4

1 に答える 1

0

コードの動作方法と余分な行$TrafficManagerProfile = Get-AzureRmTrafficManagerProfile -Name "TMName" -ResourceGroupName "TMRGName"が原因で、これが失敗します。

1 つのエンドポイントの Traffic Manager プロファイルに構成を追加してから、それを設定しようとしています。Set-AzureRmTrafficManagerProfile最初のサンプルと同じになるようにコードを変更する必要があります。違いは、2 番目の例では 2 回ではなく、Traffic Manager プロファイルを取得し、エンドポイントを追加してから 1 回呼び出すことです。

編集:プロファイルでエンドポイントを取得するためのコードを追加します。

$Profiles = Get-AzureRmTrafficManagerProfile -Name mctmp -ResourceGroupName TM

foreach ($Profile in $Profiles.Endpoints.Name) {
    Get-AzureRmTrafficManagerEndpoint -Name $Profile -ProfileName $Profiles.RelativeDnsName -ResourceGroupName TM -Type ExternalEndpoints
}
于 2016-11-17T10:33:27.590 に答える