Azure Application Gatewayの開始、停止、確認に使うコマンド一覧(課金を止める方法)

2020-01-19Application Gateway,Azure,PowerShell/Azure CLI

Azure Application Gateway(アプリケーションゲートウェイ)を開始、停止し、課金を停止する方法です。
Azure CLIおよびAzure PowerShellを使用して、Azure Application Gatewayの開始、停止、詳細情報確認を行うコマンドを一覧表にまとめています。
課金の概要やAzure Portalで開始、停止状態を確認する方法についても紹介しています。

Azure Application Gatewayリソースを停止すると、Application Gateway自体の課金を停止できます。
ただし、Azure Portalからは開始、停止操作を実行できないため、Azure CLIやAzure PowerShellを使用する必要があります。

スポンサーリンク

Azure Application Gatewayの課金概要(停止すると本体課金は止まる)

Azure Application Gatewayの課金について

Azure Application Gateway V2の課金は、固定料金と容量ユニット料金の2つの要素で構成されます。

Azure Application GatewayとWAFの価格について
Application Gateway の価格

    • 固定料金
      • Application Gatewayがデプロイされている時間に対して発生する
      • 稼働中は、インスタンス数や処理量とは別に固定料金が発生する
    • 容量ユニット料金
      • 実際の処理量、接続数、コンピューティング使用量などに応じて発生する
      • 料金は使用された容量ユニット(CU)に応じて変動する

特に、Webアプリケーションファイアウォール(WAF) V2を利用する場合は、固定料金が高くなります。
検証環境などで夜間に使用しない場合であっても、デプロイしているだけで固定料金の課金が発生します。

※課金に関しては、必ず公式ドキュメントをご確認ください。

リソースを停止させると課金も止まる

Azure Application Gatewayが停止状態の場合、課金は発生しません。

Application Gateway に関してよく寄せられる質問

よく寄せられる質問のApplication Gateway を停止して開始するにはどうすればよいですか?の項目を参照してください。

※Azure Application GatewayのフロントエンドIPとして利用しているパブリックIPに対する課金は、リソースを停止しても引き続き発生します。

1時間未満でも1時間分の課金が発生

1時間未満の利用でも1時間分として課金されるため、短時間の開始と停止を繰り返すと、課金額が想定より増える可能性があります。

Azure Portalを使ってリソースを開始、停止できない

Azure Application Gatewayの開始および停止操作は、Azure Portalからは実行できません。
そのため、Azure CLIまたはAzure PowerShellなどを使用して操作する必要があります。

リソースの設定変更すると自動的に開始することがある

停止中のAzure Application Gatewayに対して設定を変更すると、変更内容によってはリソースが自動的に開始する場合があります。
例えば、正常性プローブやリスナーの設定を変更した際に、リソースが開始することがあります。
そのため、停止状態を維持したい場合は、設定変更後にAzure Application Gatewayの状態を確認することをおすすめします。

Azure Application Gatewayの一覧、詳細情報(ステータス)取得、開始、停止に使うコマンド

確認に使用した環境(バージョン)

以下のバージョンの環境で動作確認を行っています。

    • PowerShell : 7.6.0
    • Azure CLI : 2.84.0
    • Az Module : 15.4.0
    • Az.Network : 7.25.1

Azure CLIやAzure PowerShellのインストールについては、以下の記事で紹介しています。

Azure Cloud Shellの使い方については、以下の記事で紹介しています。

リソース一覧や詳細情報(ステータス)の取得に使うAzure CLIとAzure PowerShell

Azure Application Gatewayのリソース一覧取得や情報の確認に使用するAzure CLIコマンドおよびAzure PowerShellコマンドレットの一覧です。
稼働中、停止済みといった動作状態は、OperationalStateの項目で確認できます。

操作内容 Azure CLI Azure PowerShell
リソースの一覧を取得 az network application-gateway list –output table Get-AzApplicationGateway | ft Name,Location,ResourceGroupName,OperationalState,ProvisioningState
リソースの一覧を取得
(リソースグループ指定)
az network application-gateway list –resource-group “リソースグループ名" –output table Get-AzApplicationGateway -ResourceGroupName “リソースグループ名" | ft Name,Location,ResourceGroupName,OperationalState,ProvisioningState
詳細情報(ステータス)を取得 サブスクリプション内すべて
az network application-gateway list

リソースグループ内すべて
az network application-gateway list –resource-group “リソースグループ名"

個別のリソース
az network application-gateway show –resource-group “リソースグループ名" –name “Azure Application Gateway名"

サブスクリプション内すべて
Get-AzApplicationGateway

リソースグループ内すべて
Get-AzApplicationGateway -ResourceGroupName “リソースグループ名"

個別のリソース
Get-AzApplicationGateway -ResourceGroupName “リソースグループ名" -name “Azure Application Gateway名"

※Azure PowerShellの場合は詳細情報が表示されるため、項目を指定して表形式(Format-Table)で表示しています。
※Azure CLIの–resource-groupは-g、–nameは-nと省略できます。
※Azure CLIで詳細情報を取得する際も、–output tableを指定することで表形式で取得できます。

Azureテナントへのログイン方法は、以下の記事で紹介しています。

開始および停止時に使うAzure CLIとAzure PowerShell

Azure Application Gatewayの開始および停止に使用するAzure CLIコマンドやAzure PowerShellコマンドレットです。

操作内容 Azure CLI Azure PowerShell
開始 az network application-gateway start –resource-group “リソースグループ名" –name “Azure Application Gateway名" $AppGw = Get-AzApplicationGateway -ResourceGroupName “リソースグループ名" -name “Azure Application Gateway名"
Start-AzApplicationGateway -ApplicationGateway $AppGw
停止

az network application-gateway stop –resource-group “リソースグループ名" –name “Azure Application Gateway名" $AppGw = Get-AzApplicationGateway -ResourceGroupName “リソースグループ名" -name “Azure Application Gateway名"
Stop-AzApplicationGateway -ApplicationGateway $AppGw

※Azure CLIの–resource-groupは-g、–nameは-nと省略できます。

—広告—

Azure CLIを使ってAzure Application Gatewayを操作

リソースの一覧表示や詳細情報を取得して表示

az network application-gateway showコマンドまたはaz network application-gateway listコマンドを使用して、Azure Application Gatewayのリソース情報を取得できます。

リソースに関する情報を取得して表示

PS C:\> az network application-gateway list –output table
DefaultPredefinedSslPolicy EnableFips EnableHttp2 Location Name OperationalState ProvisioningState ResourceGroup ResourceGuid
—————————- ———— ————- ———- —————- —————— ——————- ————— ————————————
AppGwSslPolicy20220101 False True japaneast agw-01 Stopped Succeeded リソースグループ名 xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

PS C:\> az network application-gateway show –resource-group “リソースグループ名" –name “agw-01" 

{
  “backendAddressPools": [
    {
      “backendAddresses": [],
      “backendIPConfigurations": [
        {
          “id": “仮想マシンのネットワークインターフェースのリソースID",
          “resourceGroup": “仮想マシンのリソースグループ名"
        }
      ],
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “id": “バックエンドのリソースID",
      “name": “バックエンドプール名",
      “provisioningState": “Succeeded",
      “resourceGroup": “リソースグループ名",
      “type": “Microsoft.Network/applicationGateways/backendAddressPools"
    }
  ],
  “backendHttpSettingsCollection": [
    {
      “affinityCookieName": “ApplicationGatewayAffinity",
      “cookieBasedAffinity": “Disabled",
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “id": “バックエンドのリソースID",
      “name": “バックエンド名",
      “pickHostNameFromBackendAddress": false,
      “port": 80,
      “protocol": “Http",
      “provisioningState": “Succeeded",
      “requestTimeout": 20,
      “resourceGroup": “リソースグループ名",
      “type": “Microsoft.Network/applicationGateways/backendHttpSettingsCollection"
    }
  ],
  “backendSettingsCollection": [],
  “defaultPredefinedSslPolicy": “AppGwSslPolicy20220101",
  “enableFips": false,
  “enableHttp2": true,
  “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
  “frontendIPConfigurations": [
    {
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “id": “フロントエンドIPのリソースID",
      “name": “フロントエンドIP名",
      “privateIPAllocationMethod": “Dynamic",
      “provisioningState": “Succeeded",
      “publicIPAddress": {
        “id": “パブリックIPアドレスのリソースID",
        “resourceGroup": “リソースグループ名"
      },
      “resourceGroup": “リソースグループ名",
      “type": “Microsoft.Network/applicationGateways/frontendIPConfigurations"
    }
  ],
  “frontendPorts": [
    {
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “id": “フロントエンドポートのリソースID",
      “name": “port_80",
      “port": 80,
      “provisioningState": “Succeeded",
      “resourceGroup": “リソースグループ名",
      “type": “Microsoft.Network/applicationGateways/frontendPorts"
    }
  ],
  “gatewayIPConfigurations": [
    {
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “id": “",
      “name": “appGatewayIpConfig",
      “provisioningState": “Succeeded",
      “resourceGroup": “リソースグループ名",
      “subnet": {
        “id": “サブネットのリソースID",
        “resourceGroup": “リソースグループ名"
      },
      “type": “Microsoft.Network/applicationGateways/gatewayIPConfigurations"
    }
  ],
  “httpListeners": [
    {
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “firewallPolicy": {
        “id": “ファイアウォールポリシーのリソースID発行",
        “resourceGroup": “リソースグループ名"
      },
      “frontendIPConfiguration": {
        “id": “フロントエンドIP構成のリソースID",
        “resourceGroup": “リソースグループ名"
      },
      “frontendPort": {
        “id": “フロントエンドポートのリソースID",
        “resourceGroup": “リソースグループ名"
      },
      “hostNames": [],
      “id": “リスナーのリソースID",
      “name": “リスナー名",
      “protocol": “Http",
      “provisioningState": “Succeeded",
      “requireServerNameIndication": false,
      “resourceGroup": “リソースグループ名",
      “type": “Microsoft.Network/applicationGateways/httpListeners"
    }
  ],
  “id": “アプリケーションゲートウェイのリソースID",
  “listeners": [],
  “loadDistributionPolicies": [],
  “location": “japaneast",
  “name": “agw-01",
  “operationalState": “Stopped",
  “privateEndpointConnections": [],
  “privateLinkConfigurations": [],
  “probes": [
    {
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “id": “正常性プローブのリソースID",
      “interval": 30,
      “match": {
        “body": “",
        “statusCodes": [
          “200-399"
        ]
      },
      “minServers": 0,
      “name": “正常性プローブ名",
      “path": “/",
      “pickHostNameFromBackendHttpSettings": true,
      “protocol": “Http",
      “provisioningState": “Succeeded",
      “resourceGroup": “リソースグループ名",
      “timeout": 30,
      “type": “Microsoft.Network/applicationGateways/probes",
      “unhealthyThreshold": 3
    }
  ],
  “provisioningState": “Succeeded",
  “redirectConfigurations": [],
  “requestRoutingRules": [
    {
      “backendAddressPool": {
        “id": “バックエンドプールのリソースID",
        “resourceGroup": “リソースグループ名"
      },
      “backendHttpSettings": {
        “id": “バックエンド設定のリソースID",
        “resourceGroup": “リソースグループ名"
      },
      “etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “httpListener": {
        “id": “リスナーのリソースID",
        “resourceGroup": “リソースグループ名"
      },
      “id": “ルールのリソースID",
      “name": “ルール名",
      “priority": 1,
      “provisioningState": “Succeeded",
      “resourceGroup": “リソースグループ名",
      “ruleType": “Basic",
      “type": “Microsoft.Network/applicationGateways/requestRoutingRules"
    }
  ],
  “resourceGroup": “リソースグループ名",
  “resourceGuid": “xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  “rewriteRuleSets": [],
  “routingRules": [],
  “sku": {
    “capacity": 2,
    “family": “Generation_1",
    “name": “WAF_v2",
    “tier": “WAF_v2"
  },
  “sslCertificates": [],
  “sslProfiles": [],
  “tags": {},
  “trustedClientCertificates": [],
  “trustedRootCertificates": [],
  “type": “Microsoft.Network/applicationGateways",
  “urlPathMaps": [],
  “webApplicationFirewallConfiguration": {
    “disabledRuleGroups": [],
    “enabled": true,
    “exclusions": [],
    “fileUploadLimitInMb": 100,
    “firewallMode": “Detection",
    “maxRequestBodySizeInKb": 128,
    “requestBodyCheck": true,
    “ruleSetType": “OWASP",
    “ruleSetVersion": “3.2"
  },
  “zones": [
    “1",
    “2",
    “3"
  ]
}

Azure CLIコマンドを使用したAzure Application Gatewayの操作例(停止、開始)

Azure CLIを使用したAzure Application Gatewayの停止から開始までの流れを確認します。
それぞれのコマンド実行後にOperationalStateでリソースの動作状態を確認します。
停止済みの場合はStopped、実行中の場合はRunningとなります。

操作内容 コマンド実行内容
 停止

PS C:> az network application-gateway stop –resource-group “リソースグループ名" –name “agw-01"

停止済みのステータス

PS C:> az network application-gateway show –resource-group “リソースグループ名" –name “agw-01" –query “{Name:name, RGName:resourceGroup, State:operationalState}" –output table
Name RGName State
—— ——– ——-
agw-01 リソースグループ名 Stopped

 開始

PS C:> az network application-gateway start –resource-group “リソースグループ名" –name “agw-01"

実行中のステータス

PS C:> az network application-gateway show –resource-group “リソースグループ名" –name “agw-01" –query “{Name:name, RGName:resourceGroup, State:operationalState}" –output table
Name RGName State
—— ——– ——-
agw-01 リソースグループ名 Running

—広告—

Azure PowerShellを使ってAzure Application Gatewayを操作

リソースの一覧表示や詳細情報を取得して表示

Get-AzApplicationGatewayコマンドレットを使用して、Azure Application Gatewayのリソース情報を取得できます

リソースに関する情報を取得して表示

PS C:\> Get-AzApplicationGateway | ft Name,Location,ResourceGroupName,OperationalState,ProvisioningState

Name Location ResourceGroupName OperationalState ProvisioningState
—- ——– —————– —————- —————–
agw-01 japaneast リソースグループ名 Stopped Succeeded

PS C:\> Get-AzApplicationGateway -ResourceGroupName “リソースグループ名" -name “agw-01" | Format-Custom * -Depth 5

class PSApplicationGateway
{
  Sku =
    class PSApplicationGatewaySku
    {
      Name = WAF_v2
      Tier = WAF_v2
      Capacity = 2
      Family = Generation_1
    }
  SslPolicy =
  GlobalConfiguration =
  GatewayIPConfigurations =
  ~(中略)~
  FrontendIPConfigurations =
    [
      class PSApplicationGatewayFrontendIPConfiguration
      {
        PrivateIPAddress =
        PrivateIPAllocationMethod = Dynamic
        Subnet =
        PublicIPAddress =
          class PSResourceId
          {
            Id = パブリックIPアドレスのリソースID
          }
        ProvisioningState = Succeeded
        Type = Microsoft.Network/applicationGateways/frontendIPConfigurations
        PrivateLinkConfiguration =
        SubnetText = null
        PublicIpAddressText = {
          “Id": “パブリックIPアドレスのリソースID"
        }
        PrivateLinkConfigurationText = null
        Name = appGwPublicFrontendIpIPv4
        Etag = W/"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        Id = アプリケーションゲートウェイのフロントエンドIP構成のリソースID
      }
    ]
  FrontendPorts =
    [
      class PSApplicationGatewayFrontendPort
      {
        Port = 80
        ProvisioningState = Succeeded
        Type = Microsoft.Network/applicationGateways/frontendPorts
        Name = port_80
        Etag = W/"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        Id = フロントエンドポートのリソースID
      }
    ]
  Probes =
    [
      class PSApplicationGatewayProbe
      {
        Protocol = Http
        Host =
        Path = /
        Interval = 30
        Timeout = 30
        UnhealthyThreshold = 3
        PickHostNameFromBackendHttpSettings = True
        MinServers = 0
        Port =
        EnableProbeProxyProtocolHeader = False
        Match =
          class PSApplicationGatewayProbeHealthResponseMatch
          {
            Body =
            StatusCodes =
              [
                200-399
              ]
            StatusCodesText = [
              “200-399"
            ]
          }
        ProvisioningState = Succeeded
        Type = Microsoft.Network/applicationGateways/probes
        MatchText = {
          “Body": “",
          “StatusCodes": [
            “200-399"
          ]
        }
        Name = 正常性プローブ名
        Etag = W/"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        Id = 正常性プローブのリソースID
      }
    ]
  BackendAddressPools =
  ~(中略)~
        ProvisioningState = Succeeded
        Type = Microsoft.Network/applicationGateways/backendAddressPools
        BackendAddressesText = []
        BackendIpConfigurationsText = [
          {
            “Id": “仮想マシンのネットワークインターフェースのリソースID",
            “Primary": false,
            “VirtualNetworkTaps": []
          }
        ]
        Name = バックエンドプール名
        Etag = W/"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        Id = バックエンドプールのリソースID
      }
    ]
  BackendHttpSettingsCollection =
   ~(中略)~
  HttpListeners =
  ~(中略)~
        Protocol = Http
        HostName =
        HostNames =
        SslCertificate =
        RequireServerNameIndication = False
        ProvisioningState = Succeeded
        Type = Microsoft.Network/applicationGateways/httpListeners
        CustomErrorConfigurations =
        FirewallPolicy =
          class PSResourceId
          {
            Id = WAFポリシーのリソースID
          }
        SslProfile =
        FrontendIpConfigurationText = {
          “Id": “フロントエンドIP構成のリソースID"
        }
        FrontendPortText = {
          “Id": “フロントエンドポートのリソースID"
        }
        SslCertificateText = null
        SslProfileText = null
        FirewallPolicyText = {
          “Id": “WAFポリシーのリソースID"
        }
        Name = listener-01
        Etag = W/"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        Id = リソースのリソースID
      }
    ]
  RequestRoutingRules =
    [
      class PSApplicationGatewayRequestRoutingRule
      {
        RuleType = Basic
        Priority = 1
        BackendAddressPool =
          class PSResourceId
          {
            Id = バックエンドプールのリソースID
          }
        BackendHttpSettings =
          class PSResourceId
          {
            Id = バックエンドのリソースID
          }
        HttpListener =
          class PSResourceId
          {
            Id = リスナーのリソースID
          }
        UrlPathMap =
        RewriteRuleSet =
        RedirectConfiguration =
        ProvisioningState = Succeeded
        Type = Microsoft.Network/applicationGateways/requestRoutingRules
        BackendAddressPoolText = {
          “Id": “バックエンドプールのリソースID"
        }
        BackendHttpSettingsText = {
          “Id": “バックエンドのリソースID"
        }
        HttpListenerText = {
          “Id": “リスナーのリソースID"
        }
        UrlPathMapText = null
        RewriteRuleSetText = null
        RedirectConfigurationText = null
        Name = ルール名
        Etag = W/"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
        Id = ルールのリソースID
      }
    ]
  WebApplicationFirewallConfiguration =
    class PSApplicationGatewayWebApplicationFirewallConfiguration
    {
      Enabled = True
      FirewallMode = Detection
      RuleSetType = OWASP
      RuleSetVersion = 3.2
      DisabledRuleGroups =
      RequestBodyCheck = True
      MaxRequestBodySizeInKb = 128
      FileUploadLimitInMb = 100
      Exclusions =
      DisabledRuleGroupsText = []
      ExclusionsText = []
    }
  FirewallPolicy =
  AutoscaleConfiguration =
  CustomErrorConfigurations =
  PrivateLinkConfigurations =
  PrivateEndpointConnections =
  EnableHttp2 = True
  EnableFips =
  EnableRequestBuffering = True
  EnableResponseBuffering =
  ForceFirewallPolicyAssociation =
  Zones =
    [
      1
      2
      3
    ]
   
  OperationalState = Stopped
  ProvisioningState = Succeeded
  Identity =
  DefaultPredefinedSslPolicy = AppGwSslPolicy20220101
  GatewayIpConfigurationsText = [
    {
      “Subnet": {
        “Id": “サブネットのリソースID"
      },
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/gatewayIPConfigurations",
      “Name": “appGatewayIpConfig",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “フロントエンドIP構成のリソースID"
    }
  ]
  TrustedClientCertificatesText = []
  AuthenticationCertificatesText = []
  SslCertificatesText = []
  FrontendIpConfigurationsText = [
    {
      “PrivateIPAllocationMethod": “Dynamic",
      “PublicIPAddress": {
        “Id": “パブリックIPアドレスのリソースID"
      },
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/frontendIPConfigurations",
      “Name": “appGwPublicFrontendIpIPv4",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “フロントエンドIP構成のリソースID"
    }
  ]
  FrontendPortsText = [
    {
      “Port": 80,
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/frontendPorts",
      “Name": “port_80",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “フロントエンドポートのリソースID"
    }
  ]
  BackendAddressPoolsText = [
    {
      “BackendAddresses": [],
      “BackendIpConfigurations": [
        {
          “Id": “仮想マシンのネットワークインターフェースのリソースID",
          “Primary": false,
          “VirtualNetworkTaps": []
        }
      ],
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/backendAddressPools",
      “Name": “バックエンドプール名",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “バックエンドプールのリソースID"
    }
  ]
  BackendHttpSettingsCollectionText = [
    {
      “Port": 80,
      “Protocol": “Http",
      “CookieBasedAffinity": “Disabled",
      “RequestTimeout": 20,
      “AuthenticationCertificates": [],
      “TrustedRootCertificates": [],
      “PickHostNameFromBackendAddress": false,
      “AffinityCookieName": “ApplicationGatewayAffinity",
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/backendHttpSettingsCollection",
      “DedicatedBackendConnection": false,
      “ValidateCertChainAndExpiry": true,
      “ValidateSNI": true,
      “Name": “バックエンド名",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “バックエンドのリソースID"
    }
  ]
  BackendSettingsCollectionText = []
  SslProfilesText = []
  HttpListenersText = [
    {
      “FrontendIpConfiguration": {
        “Id": “フロントエンドIP構成のリソースID"
      },
      “FrontendPort": {
        “Id": “フロントエンドポートのリソースID"
      },
      “Protocol": “Http",
      “HostNames": [],
      “RequireServerNameIndication": false,
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/httpListeners",
      “CustomErrorConfigurations": [],
      “FirewallPolicy": {
        “Id": “WAFポリシーのリソースID"
      },
      “Name": “listener-01",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “リスナーのリソースID"
    }
  ]
  ListenersText = []
  RewriteRuleSetsText = []
  RequestRoutingRulesText = [
    {
      “RuleType": “Basic",
      “Priority": 1,
      “BackendAddressPool": {
        “Id": “バックエンドプールのリソースID"
      },
      “BackendHttpSettings": {
        “Id": “バックエンドのリソースID"
      },
      “HttpListener": {
        “Id": “リソースのリソースID"
      },
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/requestRoutingRules",
      “Name": “rule-01",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “ルールのリソースID"
    }
  ]
  RoutingRulesText = []
  ProbesText = [
    {
      “Protocol": “Http",
      “Path": “/",
      “Interval": 30,
      “Timeout": 30,
      “UnhealthyThreshold": 3,
      “PickHostNameFromBackendHttpSettings": true,
      “MinServers": 0,
      “EnableProbeProxyProtocolHeader": false,
      “Match": {
        “Body": “",
        “StatusCodes": [
          “200-399"
        ]
      },
      “ProvisioningState": “Succeeded",
      “Type": “Microsoft.Network/applicationGateways/probes",
      “Name": “正常性プローブ名",
      “Etag": “W/\"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"",
      “Id": “正常性プローブのリソースID"
    }
  ]
  UrlPathMapsText = []
  IdentityText = null
  SslPolicyText = null
  FirewallPolicyText = null
  PrivateLinkConfigurationsText = []
  PrivateLinkEndpointConnectionsText = []
  ResourceGroupName = リソースグループ名
  Location = japaneast
  ResourceGuid = xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
  Type = Microsoft.Network/applicationGateways
  Tag =
  TagsTable =
  Name = agw-01
  Etag = W/"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  Id = アプリケーションゲートウェイのリソースID
}

Azure PowerShellを使用したAzure Application Gatewayの操作例(停止、開始)

Azure PowerShellを使用したAzure Application Gatewayの停止から開始までの流れを確認します。
それぞれのコマンド実行後にOperationalStateでリソースの動作状態を確認します。
停止済みの場合はStopped、実行中の場合はRunningとなります。

操作内容 コマンド実行内容
 停止

PS C:> $AppGw = Get-AzApplicationGateway -Name “agw-01" -ResourceGroupName “リソースグループ名"
PS C:> Stop-AzApplicationGateway -ApplicationGateway $AppGw

ResourceGroupName Name Location Sku Name Policy Name EnableHttp2 EnableFips ForceFirewallPolicyAssociation OperationalState ProvisioningState Identity
—- —- —- —- —- —- —- —- —- —- —-
リソースグループ名 agw-01 japaneast WAF_v2 True Stopped Succeeded

停止済みのステータス

PS C:> Get-AzApplicationGateway -Name “agw-01" -ResourceGroupName “リソースグループ名"| ft Name,Location,ResourceGroupName,OperationalState

Name Location ResourceGroupName OperationalState
—- —- —- —-
agw-01 japaneast リソースグループ名 Stopped

 開始

PS C:> $AppGw = Get-AzApplicationGateway -Name “agw-01" -ResourceGroupName “リソースグループ名"
PS C:> 
Start-AzApplicationGateway -ApplicationGateway $AppGw

ResourceGroupName Name Location Sku Name Policy Name EnableHttp2 EnableFips ForceFirewallPolicyAssociation OperationalState ProvisioningState Identity
—- —- —- —- —- —- —- —- —- —- —-
リソースグループ名 agw-01 japaneast WAF_v2 True Running Succeeded

実行中のステータス

PS C:> Get-AzApplicationGateway -Name “agw-01" -ResourceGroupName “リソースグループ名"| ft Name,Location,ResourceGroupName,OperationalState

Name Location ResourceGroupName OperationalState
—- —- —- —-
agw-01 japaneast リソースグループ名 Running

Azure PortalでAzure Application Gatewayの開始、停止状態を確認

Azure Application Gatewayの開始および停止状態は、Azure Portalで確認できます。
プロパティの動作状態で確認できます。
停止している場合、動作状態は停止済みと表示されます。
開始や停止を実行中の場合、プロビジョニング状態は更新中と表示されます。

実行中 停止中 停止済み 開始中
実行中(Azure Application Gatewayの動作状態) 停止中(Azure Application Gatewayの動作状態) 停止済み(Azure Application Gatewayの動作状態) 開始中(Azure Application Gatewayの動作状態)

リージョンのリソース枯渇により開始できないことがある

リージョン内のリソース(コンピューティング容量)が不足している場合、Azure Application Gatewayの開始に失敗する可能性があります。
この場合は、しばらく時間をおいてから再度開始を試みるか、別のリージョンの使用を検討してください。

最後に

Azure CLIやAzure PowerShellを使用してAzure Application Gatewayを開始および停止に使うコマンドを紹介しました。
リソースの開始や停止には5分程度かかる場合がありますが、停止することでApplication Gateway本体の課金を止められるため、コスト削減に有効です。
特に検証環境などでは、使用しない時間帯に停止しておくことで、コストを抑えられます。

引き続き、いろいろ試していきたいと思います。

Azure Firewall(ファイアウォール)の開始停止については、以下の記事で紹介しています。

Azure Application Gatewayの概要やリソース作成手順については、以下の記事で紹介しています。

スポンサーリンク