{"id":4262,"date":"2018-01-30T21:56:34","date_gmt":"2018-01-30T12:56:34","guid":{"rendered":"https:\/\/www.syuheiuda.com\/?p=4262"},"modified":"2018-10-12T00:18:47","modified_gmt":"2018-10-11T15:18:47","slug":"azure-powershell-%e3%81%a7%e3%83%87%e3%83%bc%e3%82%bf%e3%82%bb%e3%83%b3%e3%82%bf%e3%83%bc%e3%81%ae-ip-%e3%82%a2%e3%83%89%e3%83%ac%e3%82%b9%e5%b8%af%e3%82%92%e4%b8%80%e6%8b%ac%e7%99%bb%e9%8c%b2","status":"publish","type":"post","link":"https:\/\/www.syuheiuda.com\/?p=4262","title":{"rendered":"Azure PowerShell \u3067\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc\u306e IP \u30a2\u30c9\u30ec\u30b9\u5e2f\u3092\u4e00\u62ec\u767b\u9332\u3059\u308b"},"content":{"rendered":"<p><a href=\"https:\/\/www.syuheiuda.com\/?p=4251\">\u524d\u56de<\/a>\u306b\u5f15\u304d\u7d9a\u304d NSG \u306e Augmented rules \u7d61\u307f\u3067\u3059\u3002<\/p>\n<p>Azure PowerShell \u3067<a href=\"https:\/\/www.microsoft.com\/en-us\/download\/details.aspx?id=41653\">\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc IP \u30ec\u30f3\u30b8<\/a>\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u304d\u3066\u3001\u30ea\u30fc\u30b8\u30e7\u30f3\u4e8b\u306b\u4e00\u62ec\u767b\u9332\u3059\u308b\u306e\u3092\u30b5\u30af\u3063\u3068\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<br \/>\n<a href=\"https:\/\/www.syuheiuda.com\/?p=4158\">\u5148\u306e\u8a18\u4e8b<\/a>\u3067\u3082\u66f8\u3044\u305f\u901a\u308a IP \u30ec\u30f3\u30b8\u306f\u66f4\u65b0\u3055\u308c\u308b\u53ef\u80fd\u6027\u304c\u3042\u308b\u306e\u3067\u3001Azure Automation \u3068\u304b\u3067\u6bce\u9031\u5b9f\u884c\u3059\u308b\u3088\u3046\u306b\u4ed5\u8fbc\u3080\u306e\u306f\u5fc5\u9808\u3067\u3002<\/p>\n<p><del>\u3042\u3068\u306f\u3001\u3071\u3063\u3068\u78ba\u8a8d\u3057\u305f\u9650\u308a\u3001Augmented rules \u306f SourceAddressPrefix \/ DestinationAddressPrefix \u3068\u3082\u306b 2000 \u500b\u305a\u3064\u304c\u4e0a\u9650\u306e\u3088\u3046\u3067\u3001\u65e2\u306b Azure \u306e\u30c7\u30fc\u30bf\u30bb\u30f3\u30bf\u30fc IP \u30ec\u30f3\u30b8\u304c 1970 \u306a\u306e\u3067\u3001\u4eca\u4ee5\u4e0a\u306b\u5897\u3048\u305f\u3089\u6ea2\u308c\u305d\u3046\u3067\u3057\u305f\u2026\u3002\u304a\u3068\u306a\u3057\u304f <a href=\"https:\/\/azure.microsoft.com\/ja-jp\/updates\/service-tags-nsgs-ga\/\">Service Tags<\/a> \u3092\u4f7f\u3063\u305f\u307b\u3046\u304c\u3044\u3044\u304b\u3082\u3057\u308c\u307e\u305b\u3093\u306d\u30fc\u3002<\/del><\/p>\n<p>NSG \u306b\u8a2d\u5b9a\u3067\u304d\u308b\u4e0a\u9650\u304c 4000 \u307e\u3067\u306b\u5f15\u304d\u4e0a\u3052\u3089\u308c\u305f\u3089\u3057\u3044\u306e\u3067\u3001\u3072\u3068\u307e\u305a\u306f\u5927\u4e08\u592b\u305d\u3046\u306a\u611f\u3058\u3002<\/p>\n<pre class=\"brush: powershell; title: ; notranslate\" title=\"\"># IP Range \u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\r\n$DownloadUri = 'https:\/\/www.microsoft.com\/en-in\/download\/confirmation.aspx?id=41653'\r\n$DownloadPage = Invoke-WebRequest -Uri $DownloadUri\r\n$XmlFileUri = ($DownloadPage.RawContent.Split('&quot;') -like 'https:\/\/*PublicIps*')&#x5B;0]\r\n$Response = Invoke-WebRequest -Uri $XmlFileUri\r\n&#x5B;&#x5B;xml]]$XmlResponse = &#x5B;System.Text.Encoding]::UTF8.GetString($Response.Content)\r\n$Regions = $XmlResponse.AzurePublicIpAddresses.Region\r\n\r\n# \u65e2\u5b58\u306e NSG \u3092\u53d6\u5f97\r\n$NSG = Get-AzureRmNetworkSecurityGroup -Name 'NSG \u540d' -ResourceGroupName '\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d'\r\n\r\n# \u3082\u3057\u304f\u306f\u7a7a\u306e NSG \u3092\u4f5c\u6210\r\n# $NSG = New-AzureRmNetworkSecurityGroup -Name 'NSG \u540d' -ResourceGroupName '\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d' -Location '\u30ea\u30fc\u30b8\u30e7\u30f3\u540d'\r\n\r\n\r\n# \u5404\u30ea\u30fc\u30b8\u30e7\u30f3\u306e Inbound \u30eb\u30fc\u30eb\u3092\u8ffd\u52a0\r\n$Priority = 4000\r\n$Regions | foreach{\r\n$NSG = Add-AzureRmNetworkSecurityRuleConfig `\r\n-Name From_$($_.Name) `\r\n-NetworkSecurityGroup $NSG `\r\n-Protocol * `\r\n-SourcePortRange * `\r\n-DestinationPortRange * `\r\n-SourceAddressPrefix $_.IpRange.Subnet `\r\n-DestinationAddressPrefix * `\r\n-Access Allow `\r\n-Priority $Priority `\r\n-Direction Inbound\r\n$Priority++\r\n}\r\n\r\n# \u5404\u30ea\u30fc\u30b8\u30e7\u30f3\u306e Outbound \u30eb\u30fc\u30eb\u3092\u8ffd\u52a0\r\n$Priority = 4000\r\n$Regions | foreach{\r\n$NSG = Add-AzureRmNetworkSecurityRuleConfig `\r\n-Name To_$($_.Name) `\r\n-NetworkSecurityGroup $NSG `\r\n-Protocol * `\r\n-SourcePortRange * `\r\n-DestinationPortRange * `\r\n-SourceAddressPrefix * `\r\n-DestinationAddressPrefix $_.IpRange.Subnet `\r\n-Access Allow `\r\n-Priority $Priority `\r\n-Direction Outbound\r\n$Priority++\r\n}\r\n\r\n# \u8a2d\u5b9a\u3092\u53cd\u6620\r\nSet-AzureRmNetworkSecurityGroup -NetworkSecurityGroup $NSG\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u524d\u56de\u306b\u5f15\u304d\u7d9a\u304d NSG \u306e Augmented rules \u7d61\u307f\u3067\u3059\u3002 Azur&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/www.syuheiuda.com\/?p=4262\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_locale":"","_original_post":""},"categories":[42,39,31],"tags":[],"views":7848,"_links":{"self":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/4262"}],"collection":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4262"}],"version-history":[{"count":8,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/4262\/revisions"}],"predecessor-version":[{"id":4434,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/4262\/revisions\/4434"}],"wp:attachment":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4262"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4262"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4262"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}