0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

REST APIを利用してApplicaiton Gateway WAF のcustom ruleを更新する方法

Posted at

■目的:Applicaiton Gateway WAF のcustom ruleにblockしたいIPを追加します。たくさんある場合、手動で追加するのは面倒ですので、REST APIを利用して更新します。

注意:REST APIは前の設定を基本全部上書きしますので、CopyしたJson ファイルをちゃんと保管してください。
万が一、REST APIの不備で前の設定が全部なくなってしまったら大変ですので、保管したJsonファイルでもう一度REST APIを実施して戻せるはず。

Json ファイルの準備:

■Azure PortalのWAFのJsonファイルを全部Copyします。
概要のJsonビューをクリックします。これでjsonの内容が出てきます。
image.png

image.png

■Jsonの頭の部分を削除します。 "location":もちろん、追加したいIPを"matchValues"に手動で追加してください。
"location": "japaneast",
"properties": {
"provisioningState": "Succeeded",
"customRules": [
{
"name": "testIP",
"priority": 60,
"ruleType": "MatchRule",
"action": "Block",
"matchConditions": [
{
"matchVariables": [
{
"variableName": "RemoteAddr"
}
],
"operator": "IPMatch",
"negationConditon": true,
"matchValues": [
"14.8.30.32",
"14.8.30.55",
"10.10.0.0/24"
],
"transforms": []
}

REST APIを実行します。

準備できたJsonをREST APIのBodyに入れて実行します。REST API のリンクは以下です。
Web Application Firewall Policies - Create Or Update
https://learn.microsoft.com/en-us/rest/api/application-gateway/web-application-firewall-policies/create-or-update?view=rest-application-gateway-2024-05-01&viewFallbackFrom=rest-application-gateway-2024-03-01&tabs=HTTP#code-try-0

image.png

結果確認:追加されたIPがみれますね。

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?