{"id":3489,"date":"2016-02-12T06:45:26","date_gmt":"2016-02-11T21:45:26","guid":{"rendered":"http:\/\/www.syuheiuda.com\/?p=3489"},"modified":"2018-07-26T00:58:36","modified_gmt":"2018-07-25T15:58:36","slug":"azure-powershell-%e3%83%81%e3%83%bc%e3%83%88%e3%82%b7%e3%83%bc%e3%83%88","status":"publish","type":"post","link":"https:\/\/www.syuheiuda.com\/?p=3489","title":{"rendered":"Azure PowerShell \u30c1\u30fc\u30c8\u30b7\u30fc\u30c8"},"content":{"rendered":"<p>Azure VM \u3092 PowerShell \u3067\u4f5c\u308b\u306b\u3042\u305f\u3063\u3066\u3001\u5143\u306b\u306a\u308b\u30b5\u30f3\u30d7\u30eb\u304c\u307e\u3060\u307e\u3060\u5c11\u306a\u3044 (\u7279\u306b ARM) \u306e\u3067\u9069\u5f53\u306b\u307e\u3068\u3081\u3066\u307f\u3088\u3046\u304b\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u305d\u308c\u306f\u305d\u3046\u3068\u3001Azure \u3067 VM \u3092\u4f7f\u3046\u306a\u3089\u6700\u4f4e\u9650\u53ef\u7528\u6027\u30bb\u30c3\u30c8\u306f\u7d44\u307f\u307e\u3057\u3087\u3046\u306d\u3002\u307e\u3055\u304b\u30b7\u30f3\u30b0\u30eb \u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u3067\u672c\u756a\u74b0\u5883\u4f5c\u3063\u3066\u308b\u4eba\u306a\u3093\u3066\u3044\u306a\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3002<\/p>\n<h1>1. ASM \u3068 ARM<\/h1>\n<p>Azure \u3092\u4f7f\u3044\u8fbc\u3093\u3067\u3044\u308b\u4eba\u306a\u3089\u5f53\u7136\u77e5\u3063\u3066\u3044\u308b\u3068\u306f\u601d\u3046\u306e\u3067\u3059\u304c\u30012016\/02 \u73fe\u5728\u3001Azure \u306e\u7ba1\u7406\u6a5f\u69cb (API) \u306f ASM \u3068 ARM \u306e\u4e8c\u3064\u5b58\u5728\u3057\u307e\u3059\u3002<\/p>\n<p>ASM: Azure Service Management (<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/azure\/dn790568.aspx\">\u30b5\u30fc\u30d3\u30b9\u7ba1\u7406 API<\/a>)<br \/>\nARM: Azure Resource Manager (<a href=\"https:\/\/msdn.microsoft.com\/ja-jp\/library\/azure\/ee460799.aspx\">\u30ea\u30bd\u30fc\u30b9 \u30de\u30cd\u30fc\u30b8\u30e3\u30fc API<\/a>)<\/p>\n<p>ASM \u306f\u30af\u30e9\u30b7\u30c3\u30af\u30dd\u30fc\u30bf\u30eb\u3067\u4e3b\u306b\u4f7f\u308f\u308c\u3066\u3044\u305f API\u3001ARM \u306f\u65b0\u30dd\u30fc\u30bf\u30eb\u3068\u3068\u3082\u306b\u5c0e\u5165\u3055\u308c\u305f\u5168\u304f\u65b0\u3057\u3044 API \u3067\u3059\u3002<\/p>\n<p>\u65b0\u30dd\u30fc\u30bf\u30eb\u3067\u306f\u3001[\u4eee\u60f3\u30de\u30b7\u30f3 (\u30af\u30e9\u30b7\u30c3\u30af)] \u3068 [\u4eee\u60f3\u30de\u30b7\u30f3] \u3068\u3044\u3063\u305f\u8868\u8a18\u3084\u3001\u4eee\u60f3\u30de\u30b7\u30f3\u4f5c\u6210\u6642\u306b [\u30ea\u30bd\u30fc\u30b9 \u30de\u30cd\u30fc\u30b8\u30e3\u30fc] \u3068 [\u30af\u30e9\u30b7\u30c3\u30af] \u306e\u4e8c\u7a2e\u985e\u306e\u65b9\u5f0f\u304c\u3042\u308a\u307e\u3059\u304c\u3001\u30af\u30e9\u30b7\u30c3\u30af\u304c ASM \u30d9\u30fc\u30b9\u306e\u4eee\u60f3\u30de\u30b7\u30f3\u3001\u3082\u3046\u4e00\u65b9\u304c ARM \u3092\u4f7f\u7528\u3057\u305f\u4eee\u60f3\u30de\u30b7\u30f3\u3067\u3059\u3002V1 \u3068\u304b V2 \u306a\u3093\u3066\u547c\u3073\u65b9\u3092\u3059\u308b\u4eba\u3082\u3044\u307e\u3059\u306d\u3002\u4ed5\u7d44\u307f\u3092\u77e5\u3063\u3066\u3044\u308c\u3070\u5927\u3057\u305f\u3053\u3068\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001\u5909\u66f4\u304c\u5927\u304d\u3059\u304e\u305f\u308a\u3001\u305d\u308c\u305e\u308c\u5236\u7d04\u304c\u8272\u3005\u3068\u3042\u3063\u3066\u3001\u4e2d\u3005\u96e3\u3057\u3044\u2026<\/p>\n<h1>2. Azure PowerShell \u3092\u4f7f\u3063\u3066\u307f\u3088\u3046<\/h1>\n<p>\u9805\u76ee\u6570\u304c\u5897\u3048\u305f\u306e\u3067\u3001\u9069\u5f53\u306b\u6574\u7406\u3057\u307e\u3057\u305f\u3002<\/p>\n<p><a href=\"#General\">Azure PowerShell \u4e00\u822c<\/a><br \/>\n<a href=\"#Storage\">Storage \u7cfb<\/a><br \/>\n<a href=\"#Network\">Network \u7cfb<\/a><br \/>\n<a href=\"#Compute\">Compute \u7cfb<\/a><\/p>\n<h1><a name=\"General\"><\/a>2-1. Azure PowerShell \u4e00\u822c<\/h1>\n<h2>\u30ed\u30b0\u30a4\u30f3<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\nAdd-AzureAccount\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\nLogin-AzureRmAccount #Add-AzureRmAccount \u3067\u3082\u540c\u3058\r\n<\/pre>\n<h2>\u30ed\u30b0\u30a4\u30f3\u306e\u81ea\u52d5\u5316 (\u8106\u5f31\u306a\u306e\u3067\u57fa\u672c\u7684\u306b\u306f\u975e\u63a8\u5968\u3002Azure Automation \u3092\u4f7f\u3044\u307e\u3057\u3087\u3046)<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\nGet-AzurePublishSettingsFile #\u30d6\u30e9\u30a6\u30b6\u304c\u958b\u304f\u306e\u3067\u3001publishsettings \u30d5\u30a1\u30a4\u30eb\u3092\u4fdd\u5b58\r\nImport-AzurePublishSettingsFile -PublishSettingsFile &quot;&lt;\u4fdd\u5b58\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30eb\u30d1\u30b9&gt;&quot;\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\nSave-AzureRmProfile -Path &quot;&lt;JSON \u30d5\u30a1\u30a4\u30eb\u306e\u4fdd\u5b58\u5148&gt;&quot;\r\nSelect-AzureRmProfile -Path &quot;&lt;JSON \u30d5\u30a1\u30a4\u30eb\u306e\u30d5\u30eb\u30d1\u30b9&gt;&quot;\r\n<\/pre>\n<p>\u203b \u8a8d\u8a3c\u60c5\u5831\u3092\u30ed\u30fc\u30ab\u30eb\u4fdd\u5b58\u3059\u308b\u306e\u306f\u5371\u967a\u3059\u304e\u308b\u306e\u3067\u3001\u4f7f\u3046\u306b\u3057\u3066\u3082\u691c\u8a3c\u74b0\u5883\u306b\u3068\u3069\u3081\u308b\u3079\u304d\u3002<br \/>\n\u3042\u304f\u307e\u3067\u3082\u30c8\u30fc\u30af\u30f3\u306e\u30ad\u30e3\u30c3\u30b7\u30e5\u3092\u4fdd\u5b58\u3057\u3066\u3044\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u671f\u9650\u5207\u308c\u306b\u306a\u308b\u6c17\u304c\u3057\u307e\u3059\u3002<\/p>\n<h2>\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u4e00\u89a7\u306e\u53d6\u5f97\u3001\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u306e\u6307\u5b9a<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n\r\nGet-AzureSubscription Select-AzureSubscription \u2013SubscriptionId &quot;&lt;\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3 ID&gt;&quot;\r\nSet-Subscription \u2013SubscriptionId &quot;&lt;\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3 ID&gt;&quot; \u2013CurrentStorageAccountName &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\nGet-AzureRmSubscription Select-AzureRmSubscription \u2013SubscriptionId &quot;&lt;\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3 ID&gt;&quot;\r\n<\/pre>\n<h2>\u30ea\u30fc\u30b8\u30e7\u30f3\u306e\u53d6\u5f97<\/h2>\n<p>\u4f59\u8ac7\u3067\u3059\u304c\u3001\u65e5\u672c\u30ea\u30fc\u30b8\u30e7\u30f3\u306f\u6642\u671f\u306b\u3088\u3063\u3066\u30ea\u30bd\u30fc\u30b9\u304c\u3072\u3063\u8feb\u3057\u3066\u3044\u305f\u308a\u3059\u308b\u5834\u5408\u3082\u3042\u308b\u306e\u3067\u3001\u500b\u4eba\u7684\u306b\u306f\u6771\u30fb\u6771\u5357\u30a2\u30b8\u30a2\u304c\u304a\u3059\u3059\u3081\u3002<br \/>\n(\u904e\u53bb\u306b\u65e5\u672c\u30ea\u30fc\u30b8\u30e7\u30f3\u304c\u4e00\u90e8\u5236\u9650\u3055\u308c\u305f\u3053\u3068\u3082\u3042\u3063\u305f\u3057\u3001\u9806\u6b21\u5897\u5f37\u3057\u3066\u308b\u306b\u305b\u3088\u5897\u5f37\u306b\u306f\u6642\u9593\u3082\u304b\u304b\u308b\u3057\u3001\u65e5\u672c\u306f\u5730\u4fa1\u9ad8\u305d\u3046\u3060\u3057&#8230;)<\/p>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\nGet-AzureLocation | ft DisplayName\r\n<\/pre>\n<pre style=\"padding-left: 30px;\">\u51fa\u529b\u4f8b: \u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u306b\u3088\u3063\u3066\u5229\u7528\u53ef\u80fd\u306a\u5730\u57df\u304c\u7570\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\r\nEast US\r\nWest US\r\nSouth Central US\r\nCentral US\r\nEast US 2\r\nNorth Europe\r\nWest Europe\r\nSoutheast Asia\r\nEast Asia\r\nJapan West\r\nJapan East<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Compute).ResourceTypes | Where-Object ResourceTypeName -eq virtualMachines).Locations\r\n<\/pre>\n<pre style=\"padding-left: 30px;\">\u51fa\u529b\u4f8b: \u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u306b\u3088\u3063\u3066\u5229\u7528\u53ef\u80fd\u306a\u5730\u57df\u304c\u7570\u306a\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\r\nEast US\r\nEast US 2\r\nWest US\r\nCentral US\r\nSouth Central US\r\nNorth Europe\r\nWest Europe\r\nEast Asia\r\nSoutheast Asia\r\nJapan East\r\nJapan West\r\nNorth Central US\r\nAustralia East\r\nAustralia Southeast\r\nBrazil South<\/pre>\n<h2>\u7279\u5b9a\u30ea\u30fc\u30b8\u30e7\u30f3\u3067\u4f5c\u6210\u53ef\u80fd\u306a VM \u30b5\u30a4\u30ba\u306e\u53d6\u5f97<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n(Get-AzureLocation | Where-Object {$_.DisplayName -eq &quot;East Asia&quot;}). VirtualMachineRoleSizes\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\nGet-AzureRmVMSize -Location &quot;East Asia&quot; | Select-Object Name | Select-Object Name\r\n<\/pre>\n<h2>\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u306e\u4f5c\u6210\u30fb\u53d6\u5f97 (ARM \u306e\u307f)<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\nNew-AzureRmResourceGroup \u2013Name &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Location &quot;East Asia&quot;\r\nGet-AzureRmResourceGroup \u2013Name &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n<\/pre>\n<h1><a name=\"Storage\"><\/a>2-2. Storage \u7cfb<\/h1>\n<h2>\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210\u30fb\u53d6\u5f97\u30fb\u524a\u9664<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\nNew-AzureStorageAccount -StorageAccountName &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot; -Location &quot;East Asia&quot;\r\n&lt;# \u2013Type \u3067\u30ec\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3\u306e\u7a2e\u985e\u3092\u6307\u5b9a\u53ef\r\n-- Standard_LRS\r\n-- Standard_ZRS\r\n-- Standard_GRS\r\n-- Standard_RAGRS\r\n-- Premium_LRS#&gt;\r\n\r\nGet-AzureStorageAccount -StorageAccountName &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot;\r\nRemove-AzureStorageAccount -StorageAccountName &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot;\r\n<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\nNew-AzureRmStorageAccount \u2013StorageAccountName &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot; -Location &quot;East Asia&quot; -Type Standard_GRS \u2013ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n&lt;# ARM \u306f \u2013Type \u30aa\u30d7\u30b7\u30e7\u30f3\u5fc5\u9808\r\n-- Standard_LRS\r\n-- Standard_ZRS\r\n-- Standard_GRS\r\n-- Standard_RAGRS\r\n-- Premium_LRS#&gt;\r\n\r\nGet-AzureRmStorageAccount \u2013Name &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot; #cmdlet \u306e\u6319\u52d5\u304c\u3061\u3087\u3063\u3068\u602a\u3057\u3044\r\nRemove-AzureRmStorageAccount \u2013Name &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot; \u2013ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n<\/pre>\n<h2>\u30b9\u30c8\u30ec\u30fc\u30b8\u306e\u30ed\u30b0\u6709\u52b9\u5316<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n\r\n$Ctx = New-AzureStorageContext &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot; -StorageAccountKey &quot;&lt;\u30a2\u30af\u30bb\u30b9 \u30ad\u30fc&gt;&quot;\r\nSet-AzureStorageServiceLoggingProperty -ServiceType Blob -LoggingOperations read,write,delete -RetentionDays 5 -Context $Ctx\r\nSet-AzureStorageServiceLoggingProperty -ServiceType Table -LoggingOperations read,write,delete -RetentionDays 5 -Context $Ctx\r\nSet-AzureStorageServiceLoggingProperty -ServiceType Queue -LoggingOperations read,write,delete -RetentionDays 5 -Context $Ctx\r\n<\/pre>\n<p>&nbsp;<\/p>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n#cmdlet \u304c\u898b\u5f53\u305f\u3089\u306a\u3044\r\n<\/pre>\n<h1><a name=\"Network\"><\/a>2-3. Network \u7cfb<\/h1>\n<h2>\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af (VNET)\u3001\u30b5\u30d6\u30cd\u30c3\u30c8\u306e\u4f5c\u6210\u30fb\u53d6\u5f97\u30fb\u524a\u9664<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\nSet-AzureVNetConfig -ConfigurationPath &quot;&lt;netcfg \u30d5\u30a1\u30a4\u30eb\u306e\u30d1\u30b9&gt;&quot; #ASM \u3067\u306f VNET \u3092\u76f4\u63a5\u4f5c\u6210\u51fa\u6765\u306a\u3044\r\nGet-AzureVNetConfig -ExportToFile &quot;c:\\temp\\MyAzNets.netcfg&quot; \r\nGet-AzureVNetSite -VNetName &quot;&lt;VNET \u540d&gt;&quot;\r\nRemove-AzureVNetConfig #\u8a66\u3057\u3066\u306a\u3044\u3067\u3059\u304c\u3001\u8a2d\u5b9a\u3092\u5168\u90e8\u6d88\u3057\u305d\u3046\u306a\u306e\u3067\u8981\u6ce8\u610f\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\nNew-AzureRmVirtualNetwork -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Location &quot;East Asia&quot; -Name &quot;&lt;VNET \u540d&gt;&quot; -AddressPrefix &quot;192.168.0.0\/16&quot;\r\n$Vnet = Get-AzureRmVirtualNetwork -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Name &quot;&lt;VNET \u540d&gt;&quot;\r\nRemove-AzureRmVirtualNetwork -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Name &quot;&lt;VNET \u540d&gt;&quot;\r\n\r\nAdd-AzureRmVirtualNetworkSubnetConfig -Name &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot; -VirtualNetwork $Vnet -AddressPrefix &quot;192.168.1.0\/24&quot;\r\nGet-AzureRmVirtualNetworkSubnetConfig -Name &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot; -VirtualNetwork $Vnet\r\nRemove-AzureRmVirtualNetworkSubnetConfig -Name &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot; -VirtualNetwork $Vnet\r\n<\/pre>\n<h2>\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8 ACL \u306e\u4f5c\u6210\u30fb\u53d6\u5f97\u30fb\u524a\u9664 (ASM \u306e\u307f)<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n# !!! NSG \u3068\u306e\u4f75\u7528\u306f NG !!!\r\n\r\n# \u7a7a\u306e ACL \u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\u3057\u3066\u3001\u30eb\u30fc\u30eb\u3092\u8ffd\u52a0\r\n$Acl = New-AzureAclConfig\r\nSet-AzureAclConfig -AddRule -ACL $Acl -Order &quot;&lt;\u512a\u5148\u5ea6&gt;&quot; -Action &lt;Permit\/Deny&gt; -RemoteSubnet &quot;&lt;\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot; -Description &quot;&lt;\u8aac\u660e&gt;&quot;\r\n\r\n# \u65b0\u898f\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4f5c\u6210\u3059\u308b\u5834\u5408\r\nGet-AzureVM -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -Name &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot; | Add-AzureEndpoint -Name &quot;&lt;\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u540d&gt;&quot; -Protocol tcp -Localport &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30dd\u30fc\u30c8&gt;&quot; -PublicPort &quot;&lt;\u30d1\u30d6\u30ea\u30c3\u30af \u30dd\u30fc\u30c8&gt;&quot; -ACL $Acl | Update-AzureVM\r\n# \u65e2\u5b58\u306e\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u4e0a\u66f8\u304d\u3059\u308b\u5834\u5408\r\nGet-AzureVM -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -Name &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot; | Set-AzureEndpoint -Name &quot;&lt;\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u540d&gt;&quot; -Protocol tcp -Localport &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30dd\u30fc\u30c8&gt;&quot; -PublicPort &quot;&lt;\u30d1\u30d6\u30ea\u30c3\u30af \u30dd\u30fc\u30c8&gt;&quot; -ACL $Acl | Update-AzureVM\r\n\r\n# \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3092\u53d6\u5f97\u3057\u3066\u3001ACL \u3092\u53c2\u7167\r\n$Endpoint = Get-AzureVM -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -Name &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot; | Get-AzureEndpoint\r\n$Endpoint&#x5B;0].ACL\r\n\r\n# \u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u3054\u3068\u524a\u9664\r\nGet-AzureVM -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -Name &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot; | Remove-AzureEndpoint -Name &quot;&lt;\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\u540d&gt;&quot;\r\n<\/pre>\n<h2>\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30bb\u30ad\u30e5\u30ea\u30c6\u30a3 \u30b0\u30eb\u30fc\u30d7 (NSG) \u306e\u4f5c\u6210\u30fb\u53d6\u5f97\u30fb\u524a\u9664<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n# NSG \u3092\u4f5c\u6210\r\nNew-AzureNetworkSecurityGroup -Name &quot;&lt;NSG \u540d&gt;&quot; -Location &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3&gt;&quot; -Label &quot;&lt;\u30e9\u30d9\u30eb&gt;&quot;\r\n\r\n# NSG \u306b\u30eb\u30fc\u30eb\u3092\u8ffd\u52a0\r\nGet-AzureNetworkSecurityGroup -Name &quot;&lt;NSG \u540d&gt;&quot; | Set-AzureNetworkSecurityRule -Name &quot;&lt;\u30eb\u30fc\u30eb\u540d&gt;&quot; -Action &lt;Allow\/Deny&gt; -Protocol &lt;*\/TCP\/UDP&gt; -Type Inbound -Priority &quot;&lt;\u512a\u5148\u5ea6&gt;&quot; -SourceAddressPrefix &quot;&lt;\u63a5\u7d9a\u5143\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot; -SourcePortRange &quot;&lt;\u63a5\u7d9a\u5143\u30dd\u30fc\u30c8&gt;&quot; -DestinationAddressPrefix &quot;&lt;\u63a5\u7d9a\u5148\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot; -DestinationPortRange &quot;&lt;\u63a5\u7d9a\u5148\u30dd\u30fc\u30c8&gt;&quot;\r\n\r\n# NSG \u3092 VM \u306b\u7d10\u3065\u3051\r\nGet-AzureVM -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -Name &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot; | Set-AzureNetworkSecurityGroupAssociation -Name &quot;&lt;NSG \u540d&gt;&quot;\r\n\r\n# NSG \u3092 Subnet \u306b\u7d10\u3065\u3051\r\nSet-AzureNetworkSecurityGroupAssociation -Name &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot; -VirtualNetworkName &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot; -SubnetName &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot;\r\n\r\n# NSG \u3092\u53d6\u5f97\r\nGet-AzureNetworkSecurityGroup -Name &quot;&lt;NSG \u540d&gt;&quot; -Detailed\r\n\r\n# VM \u304b\u3089 NSG \u306e\u7d10\u3065\u3051\u3092\u524a\u9664\r\nGet-AzureVM -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -Name &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot; | Remove-AzureNetworkSecurityGroupAssociation -Name &quot;&lt;NSG \u540d&gt;&quot;\r\n\r\n# Subnet \u304b\u3089 NSG \u306e\u7d10\u3065\u3051\u3092\u524a\u9664\r\nRemove-AzureNetworkSecurityGroupAssociation -Name &quot;shuda0903vnet&quot; -VirtualNetworkName &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot; -SubnetName &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot;\r\n\r\n# NSG \u3092\u524a\u9664\r\nRemove-AzureNetworkSecurityGroup -Name &quot;&lt;NSG \u540d&gt;&quot;\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n# NSG \u3092\u4f5c\u6210\r\n$Nsg = New-AzureRmNetworkSecurityGroup -Name &quot;&lt;NSG \u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Location &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3&gt;&quot;\r\n\r\n# NSG \u306b\u30eb\u30fc\u30eb\u3092\u8ffd\u52a0\r\n$Nsg = Add-AzureRmNetworkSecurityRuleConfig  -Name &quot;&lt;\u30eb\u30fc\u30eb\u540d&gt;&quot; -NetworkSecurityGroup $nsg -Description &quot;&lt;\u8aac\u660e&gt;&quot; -Protocol &lt;*\/Tcp\/Udp&gt; -SourcePortRange &quot;&lt;\u63a5\u7d9a\u5143\u30dd\u30fc\u30c8&gt;&quot; -DestinationPortRange &quot;&lt;\u63a5\u7d9a\u5148\u30dd\u30fc\u30c8&gt;&quot; -SourceAddressPrefix &quot;&lt;\u63a5\u7d9a\u5143\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot; -DestinationAddressPrefix &quot;&lt;\u63a5\u7d9a\u5148\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot; -Access &lt;Allow\/Deny&gt; -Priority &quot;&lt;\u512a\u5148\u5ea6&gt;&quot; -Direction &lt;Inbound\/Outbound&gt;\r\n\r\n# NSG \u3092 NIC \u306b\u7d10\u3065\u3051\r\n$Nic = Get-AzureRmNetworkInterface -Name &quot;&lt;NIC \u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$Nic.NetworkSecurityGroup = $Nsg\r\nSet-AzureRmNetworkInterface -NetworkInterface $Nic\r\n\r\n# NSG \u3092 Subnet \u306b\u7d10\u3065\u3051\r\n$Vnet = Get-AzureRmVirtualNetwork -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Name &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\nSet-AzureRmVirtualNetworkSubnetConfig -VirtualNetwork $Vnet -Name &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot; -AddressPrefix &quot;&lt;\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot; -NetworkSecurityGroup $Nsg\r\nSet-AzureRmVirtualNetwork -VirtualNetwork $Vnet\r\n\r\n# \u4ee5\u4e0b\u8ffd\u8a18\u4e88\u5b9a \r\n\r\n# NSG \u3092\u53d6\u5f97\r\n# NIC \u304b\u3089 NSG \u306e\u7d10\u3065\u3051\u3092\u524a\u9664\r\n# Subnet \u304b\u3089 NSG \u306e\u7d10\u3065\u3051\u3092\u524a\u9664\r\n# NSG \u3092\u524a\u9664\r\n<\/pre>\n<h2>VPN \u3067\u30aa\u30f3\u30d7\u30ec\u5074\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8\u3092\u8ffd\u52a0<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n# PowerShell \u3067\u306f\u306a\u304f\u3001XML \u3092\u66f8\u304d\u63db\u3048\u3066\u30a4\u30f3\u30dd\u30fc\u30c8\u304c\u5fc5\u8981\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n# \u65e2\u5b58\u306e &quot;\u63a5\u7d9a&quot; \u3092\u524a\u9664\u3057\u307e\u3059\r\nRemove-AzureRmVirtualNetworkGatewayConnection -Name &quot;&lt;\u63a5\u7d9a\u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n\r\n# \u65e2\u5b58\u306e\u8a2d\u5b9a\u3092\u53d6\u5f97\u3057\u307e\u3059\r\n$LocalGW = Get-AzureRmLocalNetworkGateway -Name &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n\r\n# \u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8\u3092\u8ffd\u52a0\u3057\u307e\u3059\r\n$AddressPrefix = $LocalGW.LocalNetworkAddressSpace.AddressPrefixes\r\n$AddressPrefix += &quot;192.168.0.0\/24&quot;\r\n$AddressPrefix += &quot;192.168.1.0\/24&quot;\r\n$AddressPrefix += &quot;192.168.2.0\/24&quot;\r\n$AddressPrefix += &quot;192.168.3.0\/24&quot;\r\n\r\n# \u8a2d\u5b9a\u3092\u53cd\u6620\u3057\u307e\u3059\r\nSet-AzureRmLocalNetworkGateway -LocalNetworkGateway $LocalGW -AddressPrefix $AddressPrefix\r\n\r\n# &quot;\u63a5\u7d9a&quot; \u3092\u518d\u4f5c\u6210\u3057\u307e\u3059\r\n$GW = Get-AzureRmVirtualNetworkGateway -Name &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name &quot;&lt;\u63a5\u7d9a\u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Location &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot; -VirtualNetworkGateway1 $GW -LocalNetworkGateway2 $LocalGW -ConnectionType IPsec -RoutingWeight 10 -SharedKey &quot;&lt;\u4e8b\u524d\u5171\u6709\u30ad\u30fc&gt;&quot;\r\n<\/pre>\n<h2>\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4 (VPN Gateway) \u306e\u30b5\u30a4\u30ba (SKU) \u5909\u66f4<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\nGet-AzureVirtualNetworkGateway #VPN Gateway \u306e ID \u3092\u78ba\u8a8d\r\nResize-AzureVirtualNetworkGateway -GatewayId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -GatewaySKU &lt;Default\/Standard\/HighPerformance&gt;\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$gw = Get-AzureRmVirtualNetworkGateway -Name &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\nResize-AzureRmVirtualNetworkGateway -VirtualNetworkGateway $gw -GatewaySku &lt;Basic\/Standard\/HighPerformance&gt;\r\n# Set-AzureRmVirtualNetworkGateway -VirtualNetworkGateway $gw -GatewaySku &lt;Basic\/Standard\/HighPerformance&gt; \u3067\u3082\u540c\u3058\r\n<\/pre>\n<h2>VNet Peering \u306e\u4f5c\u6210<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n# \u63a5\u7d9a\u3059\u308b VNet \u3092\u53d6\u5f97\r\n$vnet1 = Get-AzureRmVirtualNetwork -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Name &quot;&lt;VNet \u540d 1&gt;&quot;\r\n$vnet2 = Get-AzureRmVirtualNetwork -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Name &quot;&lt;VNet \u540d 2&gt;&quot;\r\n\r\n# \u53cc\u65b9\u5411\u3067\u63a5\u7d9a\r\nAdd-AzureRmVirtualNetworkPeering -name &quot;&lt;VNet Peering \u540d 1&gt;&quot; -VirtualNetwork &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -RemoteVirtualNetworkId $vnet2.id \r\nAdd-AzureRmVirtualNetworkPeering -name &quot;&lt;VNet Peering \u540d 2&gt;&quot; -VirtualNetwork &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -RemoteVirtualNetworkId $vnet1.id \r\n\r\n# VNet Peering \u306e\u72b6\u614b\u3092\u53d6\u5f97\r\nGet-AzureRmVirtualNetworkPeering -VirtualNetworkName &quot;&lt;VNet \u540d 1&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Name &quot;&lt;VNet Peering \u540d 1&gt;&quot;\r\nGet-AzureRmVirtualNetworkPeering -VirtualNetworkName &quot;&lt;VNet \u540d 2&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -Name &quot;&lt;VNet Peering \u540d 2&gt;&quot;\r\n\r\n# VNet Peering \u3092\u524a\u9664\r\nRemove-AzureRmVirtualNetworkPeering -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -VirtualNetworkName &quot;&lt;VNet \u540d 1&gt;&quot; -Name &quot;&lt;VNet Peering \u540d 1&gt;&quot;\r\nRemove-AzureRmVirtualNetworkPeering -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot; -VirtualNetworkName &quot;&lt;VNet \u540d 2&gt;&quot; -Name &quot;&lt;VNet Peering \u540d 2&gt;&quot;\r\n<\/pre>\n<h2>Public IP \u306e\u6b63\u5f15\u304d\u30fb\u9006\u5f15\u304d\u8a2d\u5b9a<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n# \u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u306b\u5bfe\u3057\u3066\u9006\u5f15\u304d\u3092\u8a2d\u5b9a\r\nSet-AzureService -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -ReverseDnsFqdn &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;.cloudapp.net.&quot; #\u672b\u5c3e\u306b . (\u30c9\u30c3\u30c8) \u304c\u5fc5\u8981\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n# \u65e2\u5b58\u306e\u8a2d\u5b9a\u3092\u53d6\u5f97\r\n$PublicIP = Get-AzureRmPublicIpAddress -Name &quot;&lt;Public IP \u540d&gt;&quot; -ResourceGroupName &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n\r\n# \u6b63\u5f15\u304d\u540d\u3092\u8ffd\u52a0\r\n$PublicIP.DnsSettings += @{DomainNameLabel = &quot;&lt;DNS \u540d&gt;&quot;}\r\n\r\n# \u8a2d\u5b9a\u3092\u53cd\u6620\r\nSet-AzureRmPublicIpAddress -PublicIpAddress $PublicIP\r\n\r\n# \u5b9f\u884c\u7d50\u679c\u629c\u7c8b\r\n# DnsSettings              : {\r\n#                             &quot;DomainNameLabel&quot;: &quot;shuda1219&quot;,\r\n#                             &quot;Fqdn&quot;: &quot;xxx.japaneast.cloudapp.azure.com&quot;, &lt;== \u3053\u308c\u3092\u30b3\u30d4\u30fc\r\n#                             &quot;ReverseFqdn&quot;: \r\n#                           }\r\n\r\n# \u9006\u5f15\u304d\u540d\u3092\u8ffd\u52a0\r\n$PublicIP.DnsSettings.ReverseFqdn = &quot;xxx.japaneast.cloudapp.azure.com&quot;\r\n$PublicIP.DnsSettings.ReverseFqdn = &quot;xxx.contoso.com&quot; &lt;== xxx.contoso.com \u3092\u6b63\u5f15\u304d\u3057\u3066\u691c\u8a3c\u3067\u304d\u308c\u3070\u30ab\u30b9\u30bf\u30e0 \u30c9\u30e1\u30a4\u30f3\u3082\u8a2d\u5b9a\u53ef\u80fd\r\n\r\n# \u8a2d\u5b9a\u3092\u53cd\u6620\r\nSet-AzureRmPublicIpAddress -PublicIpAddress $PublicIP\r\n\r\n# \u5b9f\u884c\u7d50\u679c\u629c\u7c8b\r\n# DnsSettings              : {\r\n#                             &quot;DomainNameLabel&quot;: &quot;shuda1219&quot;,\r\n#                             &quot;Fqdn&quot;: &quot;xxx.japaneast.cloudapp.azure.com&quot;,\r\n#                             &quot;ReverseFqdn&quot;: &quot;xxx.japaneast.cloudapp.azure.com&quot;\r\n#                           }\r\n<\/pre>\n<h2>\u8907\u6570\u306e\u30d1\u30d6\u30ea\u30c3\u30af \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u3092\u6709\u3059\u308b Load Balancer \u306e\u4f5c\u6210<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n# \u3042\u3068\u3067\u66f8\u304d\u8db3\u3059\u4e88\u5b9a\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n# \u5b9a\u7fa9\r\n$SubscriptionId = &quot;&lt;\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3 ID&gt;&quot;\r\n$RgName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$Location = &quot;Japan East&quot;\r\n\r\n# \u30ed\u30b0\u30a4\u30f3\u51e6\u7406\r\nLogin-AzureRmAccount\r\nGet-AzureRmSubscription\r\nSelect-AzureRmSubscription -SubscriptionId $SubscriptionId\r\nNew-AzureRmResourceGroup -Name $RgName -location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u306e\u4f5c\u6210\r\n$backendSubnet = New-AzureRmVirtualNetworkSubnetConfig -Name LB-Subnet-BE -AddressPrefix 10.0.2.0\/24\r\nNew-AzureRmvirtualNetwork -Name NRPVNet -ResourceGroupName $RgName -Location $Location -AddressPrefix 10.0.0.0\/16 -Subnet $backendSubnet\r\n\r\n# \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u306e\u4f5c\u6210\r\n$publicIP1 = New-AzureRmPublicIpAddress -Name PublicIp1 -ResourceGroupName $RgName -Location $Location \u2013AllocationMethod Static -DomainNameLabel loadbalancernrp1\r\n$publicIP2 = New-AzureRmPublicIpAddress -Name PublicIp2 -ResourceGroupName $RgName -Location $Location \u2013AllocationMethod Static -DomainNameLabel loadbalancernrp2\r\n\r\n# \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u3092\u5b9a\u7fa9\r\n$frontendIP1 = New-AzureRmLoadBalancerFrontendIpConfig -Name LB-Frontend1 -PublicIpAddress $publicIP1\r\n$frontendIP2 = New-AzureRmLoadBalancerFrontendIpConfig -Name LB-Frontend2 -PublicIpAddress $publicIP2\r\n\r\n# \u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u3092\u4f5c\u6210\r\n$beaddresspool = New-AzureRmLoadBalancerBackendAddressPoolConfig -Name LB-backend\r\n\r\n# \u30d7\u30ed\u30fc\u30d6\u3092\u5b9a\u7fa9\r\n$healthProbe = New-AzureRmLoadBalancerProbeConfig -Name HealthProbe -RequestPath '\/' -Protocol http -Port 80 -IntervalInSeconds 15 -ProbeCount 2\r\n\r\n# \u8ca0\u8377\u5206\u6563\u30eb\u30fc\u30eb\u3092\u5b9a\u7fa9\r\n$lbrule1 = New-AzureRmLoadBalancerRuleConfig -Name HTTP1 -FrontendIpConfiguration $frontendIP1 -BackendAddressPool  $beAddressPool -Probe $healthProbe -Protocol Tcp -FrontendPort 80 -BackendPort 80\r\n$lbrule2 = New-AzureRmLoadBalancerRuleConfig -Name HTTP2 -FrontendIpConfiguration $frontendIP2 -BackendAddressPool  $beAddressPool -Probe $healthProbe -Protocol Tcp -FrontendPort 80 -BackendPort 80\r\n\r\n# LB \u3092\u4f5c\u6210\r\n$LB = New-AzureRmLoadBalancer -ResourceGroupName $RgName -Name NRP-LB -Location $Location -FrontendIpConfiguration $frontendIP1,$frontendIP2 -LoadBalancingRule $lbrule1,$lbrule2 -BackendAddressPool $beAddressPool -Probe $healthProbe\r\n<\/pre>\n<h2>Internal Load Balancer \u306e\u69cb\u6210\u5909\u66f4<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n# \u6c17\u304c\u5411\u3044\u305f\u3089\u5f8c\u3067\u66f8\u304f\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n# \u5404\u7a2e\u5909\u6570\u3092\u8a2d\u5b9a\u3057\u307e\u3059\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$IlbName = &quot;&lt;\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u30fc\u540d&gt;&quot;\r\n$VnetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\n$SubnetName = &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot;\r\n$OldFrontendIpName = &quot;&lt;\u65e7\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u540d&gt;&quot;\r\n$NewFrontendIpName = &quot;&lt;\u65b0\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u540d&gt;&quot;\r\n$NewFrontendIpAddress = &quot;&lt;\u65b0\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u30a2\u30c9\u30ec\u30b9&gt;&quot;\r\n$OldBackendAddressPoolName = &quot;&lt;\u65e7\u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u540d&gt;&quot;\r\n$NewBackendAddressPoolName = &quot;&lt;\u65b0\u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u540d&gt;&quot;\r\n$LoadBalancingRuleName = &quot;&lt;\u8ca0\u8377\u5206\u6563\u898f\u5247\u540d&gt;&quot;\r\n$NicNames = @(&quot;NIC \u540d 1&quot;,&quot;NIC \u540d 2&quot;)\r\n$NicIpConfigName = &quot;NIC \u306e IpCOnfig \u540d&quot;\r\n\r\n# \u65e2\u5b58\u306e\u30ed\u30fc\u30c9\u30d0\u30e9\u30f3\u30b5\u30fc\u306e\u69cb\u6210\u3092\u53d6\u5f97\u3057\u307e\u3059\r\n$Ilb = Get-AzureRmLoadBalancer -Name $IlbName -ResourceGroupName $ResourceGroupName\r\n\r\n# \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u3092\u914d\u7f6e\u3055\u305b\u308b VNET \u306e\u60c5\u5831\u3092\u53d6\u5f97\u3057\u307e\u3059\r\n$Vnet= Get-AzureRmVirtualNetwork -Name $VnetName -ResourceGroupName $ResourceGroupName\r\n\r\n# \u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u3092\u8ffd\u52a0\u3057\u307e\u3059\r\n$Ilb = Add-AzureRmLoadBalancerFrontendIpConfig -Name $NewFrontendIpName -LoadBalancer $Ilb -PrivateIpAddress $NewFrontendIpAddress -SubnetId ($Vnet.subnets | where Name -eq $SubnetName).Id\r\n\r\n# \u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u3092\u8ffd\u52a0\u3057\u307e\u3059\r\n$Ilb = Add-AzureRmLoadBalancerBackendAddressPoolConfig -Name $NewBackendAddressPoolName -LoadBalancer $Ilb\r\n\r\n# \u8a2d\u5b9a\u3092\u53cd\u6620\u3057\u307e\u3059\r\n$Ilb = Set-AzureRmLoadBalancer -LoadBalancer $Ilb\r\n\r\n# NIC \u306e\u6570\u3060\u3051\u30eb\u30fc\u30d7\u3055\u305b\u307e\u3059\r\nforeach($NicName in $NicNames){\r\n    # \u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u306e\u69cb\u6210\u3092\u53d6\u5f97\u3057\u307e\u3059\r\n    $Backend = Get-AzureRmLoadBalancerBackendAddressPoolConfig -name $NewBackendAddressPoolName -LoadBalancer $Ilb\r\n\r\n    # \u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u306b\u7d10\u4ed8\u3051\u308b\u65e2\u5b58\u306e NIC \u306e\u69cb\u6210\u3092\u53d6\u5f97\u3057\u307e\u3059\r\n    $Nic = Get-AzureRmNetworkInterface \u2013name $NicName -resourcegroupname $ResourceGroupName\r\n\r\n    # \u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u306b\u65e2\u5b58\u306e VM \u306e NIC \u3092\u7d10\u4ed8\u3051\u307e\u3059\r\n    ($Nic.IpConfigurations | where Name -eq $NicIpConfigName).LoadBalancerBackendAddressPools = $Backend\r\n\r\n    # NIC \u306e\u8a2d\u5b9a\u3092\u53cd\u6620\u3057\u307e\u3059\r\n    $Nic = Set-AzureRmNetworkInterface -NetworkInterface $Nic\r\n}\r\n\r\n# \u65e2\u5b58\u306e\u8ca0\u8377\u5206\u6563\u898f\u5247\u306b\u7d10\u3065\u304f\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP\u3092\u5909\u66f4\u3057\u307e\u3059\r\n($Ilb.LoadBalancingRules | where Name -eq $LoadBalancingRuleName).FrontendIPConfiguration.Id = ($Ilb.FrontendIpConfigurations | where Name -eq $NewFrontendIpName).Id\r\n\r\n# \u65e2\u5b58\u306e\u8ca0\u8377\u5206\u6563\u898f\u5247\u306b\u7d10\u3065\u304f\u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u3092\u5909\u66f4\u3057\u307e\u3059\r\n($Ilb.LoadBalancingRules | where Name -eq $LoadBalancingRuleName).BackendAddressPool.Id = ($Ilb.BackendAddressPools | where Name -eq $NewBackendAddressPoolName).Id\r\n\r\n# \u4e0d\u8981\u306b\u306a\u3063\u305f\u30d5\u30ed\u30f3\u30c8\u30a8\u30f3\u30c9 IP \u3092\u524a\u9664\u3057\u307e\u3059\r\n$Ilb = Remove-AzureRmLoadBalancerFrontendIpConfig -Name $OldFrontendIpName -LoadBalancer $ilb\r\n\r\n# \u4e0d\u8981\u306b\u306a\u3063\u305f\u30d0\u30c3\u30af\u30a8\u30f3\u30c9 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb\u3092\u524a\u9664\u3057\u307e\u3059\r\n$Ilb = Remove-AzureRmLoadBalancerBackendAddressPoolConfig -Name $OldBackendAddressPoolName -LoadBalancer $ilb\r\n\r\n# \u8a2d\u5b9a\u3092\u53cd\u6620\u3057\u307e\u3059\r\n$Ilb = Set-AzureRmLoadBalancer -LoadBalancer $Ilb\r\n<\/pre>\n<h2>\u30b5\u30a4\u30c8\u9593 VPN (\u9759\u7684 \/ Policy-Based) \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\n$VNetAddressPrefix = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix = &quot;10.0.1.0\/28&quot;\r\n$GatewayName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$GatewayPublicIpName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d&gt;&quot;\r\n$LocalNetworkGatewayName = &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$LocalNetworkGatewayIp = &quot;&lt;\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e VPN \u6a5f\u5668\u304c\u6301\u3064\u30b0\u30ed\u30fc\u30d0\u30eb IP&gt;&quot;\r\n$OnpremiseAddressPrefix = &quot;&lt;\u30ed\u30fc\u30ab\u30eb\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot;\r\n$ConnectionName = &quot;&lt;\u63a5\u7d9a\u540d&gt;&quot;\r\n$PreSharedKey = &quot;&lt;\u4e8b\u524d\u5171\u6709\u30ad\u30fc&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix\r\nNew-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\nNew-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName -Location $Location -GatewayIpAddress $LocalNetworkGatewayIp -AddressPrefix $OnpremiseAddressPrefix\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName\r\n$Subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet\r\n$GatewayIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $Subnet.Id -PublicIpAddressId $GatewayPublicIp.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig -GatewayType Vpn -VpnType PolicyBased -GatewaySku Basic\r\n\r\n# VPN Gateway \u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u3092\u53d6\u5f97 (\u3053\u3061\u3089\u3092\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e\u30eb\u30fc\u30bf\u30fc\u3067\u8a2d\u5b9a)\r\nGet-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName\r\n\r\n# \u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u3068\u306e\u63a5\u7d9a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\r\n$VNetGateway1 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName\r\n$LocalNetworkGateway2 = Get-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway1 -LocalNetworkGateway2 $LocalNetworkGateway2 -ConnectionType IPsec -RoutingWeight 10 -SharedKey $PreSharedKey\r\n<\/pre>\n<h2>\u30b5\u30a4\u30c8\u9593 VPN (\u52d5\u7684 \/ Route-Based) \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\n$VNetAddressPrefix = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix = &quot;10.0.1.0\/28&quot;\r\n$GatewayName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$GatewayPublicIpName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d&gt;&quot;\r\n$LocalNetworkGatewayName = &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$LocalNetworkGatewayIp = &quot;&lt;\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e VPN \u6a5f\u5668\u304c\u6301\u3064\u30b0\u30ed\u30fc\u30d0\u30eb IP&gt;&quot;\r\n$OnpremiseAddressPrefix = &quot;&lt;\u30ed\u30fc\u30ab\u30eb\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot;\r\n$ConnectionName = &quot;&lt;\u63a5\u7d9a\u540d&gt;&quot;\r\n$PreSharedKey = &quot;&lt;\u4e8b\u524d\u5171\u6709\u30ad\u30fc&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix\r\nNew-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\nNew-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName -Location $Location -GatewayIpAddress $LocalNetworkGatewayIp -AddressPrefix $OnpremiseAddressPrefix\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName\r\n$Subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet\r\n$GatewayIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $Subnet.Id -PublicIpAddressId $GatewayPublicIp.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig -GatewayType Vpn -VpnType RouteBased -GatewaySku Basic\r\n\r\n# VPN Gateway \u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u3092\u53d6\u5f97 (\u3053\u3061\u3089\u3092\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e\u30eb\u30fc\u30bf\u30fc\u3067\u8a2d\u5b9a)\r\nGet-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName\r\n\r\n# \u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u3068\u306e\u63a5\u7d9a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\r\n$VNetGateway1 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName\r\n$LocalNetworkGateway2 = Get-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway1 -LocalNetworkGateway2 $LocalNetworkGateway2 -ConnectionType IPsec -RoutingWeight 10 -SharedKey $PreSharedKey\r\n<\/pre>\n<h2>BGP \u3092\u4f7f\u7528\u3057\u305f\u30b5\u30a4\u30c8\u9593 VPN (\u52d5\u7684 \/ Route-Based) \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\n$VNetAddressPrefix = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix = &quot;10.0.1.0\/28&quot;\r\n$GatewayName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$GatewayPublicIpName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d&gt;&quot;\r\n$ASNumber = &quot;&lt;AS \u756a\u53f7&gt;&quot;\r\n$LocalNetworkGatewayName = &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$LocalNetworkGatewayIp = &quot;&lt;\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e VPN \u6a5f\u5668\u304c\u6301\u3064\u30b0\u30ed\u30fc\u30d0\u30eb IP&gt;&quot;\r\n$OnpremiseAddressPrefix = &quot;&lt;\u30ed\u30fc\u30ab\u30eb\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot;\r\n$ConnectionName = &quot;&lt;\u63a5\u7d9a\u540d&gt;&quot;\r\n$PreSharedKey = &quot;&lt;\u4e8b\u524d\u5171\u6709\u30ad\u30fc&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix\r\nNew-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\nNew-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName -Location $Location -GatewayIpAddress $LocalNetworkGatewayIp -AddressPrefix $OnpremiseAddressPrefix\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName\r\n$Subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet\r\n$GatewayIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $Subnet.Id -PublicIpAddressId $GatewayPublicIp.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig -GatewayType Vpn -VpnType RouteBased -GatewaySku Standard -Asn $ASNumber\r\n\r\n# VPN Gateway \u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u3092\u53d6\u5f97 (\u3053\u3061\u3089\u3092\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e\u30eb\u30fc\u30bf\u30fc\u3067\u8a2d\u5b9a)\r\nGet-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName\r\n\r\n# \u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u3068\u306e\u63a5\u7d9a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\r\n$VNetGateway1 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName\r\n$LocalNetworkGateway2 = Get-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway1 -LocalNetworkGateway2 $LocalNetworkGateway2 -ConnectionType IPsec -RoutingWeight 10 -SharedKey $PreSharedKey\r\n<\/pre>\n<h2>Active-Active \u69cb\u6210\u306e\u30b5\u30a4\u30c8\u9593 VPN (\u52d5\u7684 \/ Route-Based) \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\n$VNetAddressPrefix = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix = &quot;10.0.1.0\/28&quot;\r\n$GatewayName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$GatewayPublicIpName1 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d 1&gt;&quot;\r\n$GatewayPublicIpName2 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d 2&gt;&quot;\r\n$ASNumber = &quot;&lt;AS \u756a\u53f7&gt;&quot;\r\n$LocalNetworkGatewayName = &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$LocalNetworkGatewayIp = &quot;&lt;\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e VPN \u6a5f\u5668\u304c\u6301\u3064\u30b0\u30ed\u30fc\u30d0\u30eb IP&gt;&quot;\r\n$OnpremiseAddressPrefix = &quot;&lt;\u30ed\u30fc\u30ab\u30eb\u306e\u30a2\u30c9\u30ec\u30b9 \u30ec\u30f3\u30b8&gt;&quot;\r\n$ConnectionName = &quot;&lt;\u63a5\u7d9a\u540d&gt;&quot;\r\n$PreSharedKey = &quot;&lt;\u4e8b\u524d\u5171\u6709\u30ad\u30fc&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix\r\nNew-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\nNew-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName -Location $Location -GatewayIpAddress $LocalNetworkGatewayIp -AddressPrefix $OnpremiseAddressPrefix\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp1 = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName1 -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n$GatewayPublicIp2 = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName2 -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName\r\n$Subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet\r\n$GatewayIpConfig1 = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $Subnet.Id -PublicIpAddressId $GatewayPublicIp1.Id \r\n$GatewayIpConfig2 = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig2 -SubnetId $Subnet.Id -PublicIpAddressId $GatewayPublicIp2.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig1,$GatewayIpConfig2 -GatewayType Vpn -VpnType RouteBased -GatewaySku HighPerformance -Asn $ASNumber -ActiveActive $True\r\n\r\n# VPN Gateway \u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u3092\u53d6\u5f97 (\u3053\u3061\u3089\u3092\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e\u30eb\u30fc\u30bf\u30fc\u3067\u8a2d\u5b9a)\r\nGet-AzureRmPublicIpAddress -Name $GatewayPublicIpName1 -ResourceGroupName $ResourceGroupName\r\nGet-AzureRmPublicIpAddress -Name $GatewayPublicIpName2 -ResourceGroupName $ResourceGroupName\r\n\r\n# \u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u3068\u306e\u63a5\u7d9a\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u6210\r\n$VNetGateway1 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName\r\n$LocalNetworkGateway2 = Get-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName -ResourceGroupName $ResourceGroupName\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway1 -LocalNetworkGateway2 $LocalNetworkGateway2 -ConnectionType IPsec -RoutingWeight 10 -SharedKey $PreSharedKey\r\n<\/pre>\n<h2>\u30dd\u30a4\u30f3\u30c8\u5bfe\u30b5\u30a4\u30c8 (P2S) VPN \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\n$VNetAddressPrefix = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix = &quot;10.0.1.0\/28&quot;\r\n$GatewayName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$GatewayPublicIpName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d&gt;&quot;\r\n$ClientAddressPool = &quot;192.168.0.0\/24&quot;\r\n$RootCertName = &quot;VpnRootCert.cer&quot;\r\n$RootCertPath = &quot;C:\\Users\\Administrator\\Desktop\\VpnRootCert.cer&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix\r\nNew-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName\r\n$Subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet\r\n$GatewayIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $subnet.Id -PublicIpAddressId $GatewayPublicIp.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig -GatewayType Vpn -VpnType RouteBased -GatewaySku Basic\r\n\r\n# makecert (\u8981\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb) \u3067\u8a3c\u660e\u66f8\u3092\u4f5c\u6210\r\n&quot;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x64\\makecert.exe&quot; -sky exchange -r -n &quot;CN=VpnRootCert&quot; -pe -a sha1 -len 2048 -ss My &quot;VpnRootCert.cer&quot;\r\n&quot;C:\\Program Files (x86)\\Windows Kits\\10\\bin\\x64\\makecert.exe&quot; -n &quot;CN=VpnClientCert&quot; -pe -sky exchange -m 96 -ss My -in &quot;VpnRootCert&quot; -is my -a sha1\r\n \r\n# \u4e8b\u524d\u306b\u30af\u30e9\u30a4\u30a2\u30f3\u30c8 \u30a2\u30c9\u30ec\u30b9 \u30d7\u30fc\u30eb (\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u7aef\u672b\u306b\u6255\u3044\u51fa\u3059 IP \u30ec\u30f3\u30b8) \u3092\u8ffd\u52a0\r\n$VNetGateway = Get-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName\r\nSet-AzureRmVirtualNetworkGatewayVpnClientConfig -VirtualNetworkGateway $VNetGateway -VpnClientAddressPool $ClientAddressPool\r\n \r\n# \u30eb\u30fc\u30c8\u8a3c\u660e\u66f8\u3092\u8ffd\u52a0\r\n$RootCertBase64 = &#x5B;System.Convert]::ToBase64String(&#x5B;System.IO.File]::ReadAllBytes($RootCertPath))\r\nAdd-AzureRmVpnClientRootCertificate -VpnClientRootCertificateName $RootCertName -VirtualNetworkGatewayname $VNetGateway.Name -ResourceGroupName $VNetGateway.ResourceGroupName -PublicCertData $RootCertBase64\r\n \r\n# VPN \u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u306e\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9 (\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u53ef\u80fd\u306b\u306a\u308b\u307e\u3067\u82e5\u5e72\u6642\u9593\u304c\u304b\u304b\u308b)\r\n$ClientUrl = Get-AzureRmVpnClientPackage -ResourceGroupName $VNetGateway.ResourceGroupName -VirtualNetworkGatewayName $VNetGateway.Name -ProcessorArchitecture Amd64\r\nInvoke-WebRequest $ClientUrl\r\n\r\n# \u5225\u9014\u3001\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u7aef\u672b\u306b\u306f\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u8a3c\u660e\u66f8\u3092\u914d\u5e03\u304c\u5fc5\u8981\r\n<\/pre>\n<h2>ExpressRoute \u7528\u306e Gateway \u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;\r\n$VNetAddressPrefix = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix = &quot;10.0.1.0\/28&quot;\r\n$GatewayName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d&gt;&quot;\r\n$GatewayPublicIpName = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d&gt;&quot;\r\n$CircuitName = &quot;&lt;ExpressRoute \u30b5\u30fc\u30ad\u30c3\u30c8\u540d&gt;&quot;\r\n$ConnectionName = &quot;&lt;\u63a5\u7d9a\u540d&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix\r\nNew-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet = Get-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName\r\n$Subnet = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet\r\n$GatewayIpConfig = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $subnet.Id -PublicIpAddressId $GatewayPublicIp.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig -GatewayType Expressroute -GatewaySku Standard\r\n\r\n# ExpressRoute Circuit \u3068\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u63a5\u7d9a\r\n$Circuit = Get-AzureRmExpressRouteCircuit -Name $CircuitName -ResourceGroupName $ResourceGroupName\r\n$VNetGateway1 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName -ResourceGroupName $ResourceGroupName\r\n$Connection = New-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway1 -PeerId $Circuit.Id -ConnectionType ExpressRoute\r\n<\/pre>\n<h2>Vnet2Vnet \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName1 = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d 1&gt;&quot;\r\n$VNetAddressPrefix1 = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix1 = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix1 = &quot;10.0.1.0\/28&quot;\r\n$GatewayName1 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d 1&gt;&quot;\r\n$GatewayPublicIpName1 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d 1&gt;&quot;\r\n$VNetName2 = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d 2&gt;&quot;\r\n$VNetAddressPrefix2 = &quot;10.1.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix2 = &quot;10.1.0.0\/28&quot;\r\n$Subnet1AddressPrefix2 = &quot;10.1.1.0\/28&quot;\r\n$GatewayName2 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d 2&gt;&quot;\r\n$GatewayPublicIpName2 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d 2&gt;&quot;\r\n$ConnectionName1 = &quot;&lt;\u63a5\u7d9a\u540d 1&gt;&quot;\r\n$ConnectionName2 = &quot;&lt;\u63a5\u7d9a\u540d 2&gt;&quot;\r\n$PreSharedKey = &quot;&lt;\u4e8b\u524d\u5171\u6709\u30ad\u30fc&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix1\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix1\r\nNew-AzureRmVirtualNetwork -Name $VNetName1 -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix1 -Subnet $Subnet1, $Subnet2\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix2\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix2\r\nNew-AzureRmVirtualNetwork -Name $VNetName2 -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix2 -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp1 = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName1 -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n$GatewayPublicIp2 = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName2 -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet1 = Get-AzureRmVirtualNetwork -Name $VNetName1 -ResourceGroupName $ResourceGroupName\r\n$Subnet1 = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet1\r\n$GatewayIpConfig1 = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $Subnet1.Id -PublicIpAddressId $GatewayPublicIp1.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName1 -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig1 -GatewayType Vpn -VpnType RouteBased -GatewaySku Basic\r\n$Vnet2 = Get-AzureRmVirtualNetwork -Name $VNetName2 -ResourceGroupName $ResourceGroupName\r\n$Subnet2 = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet2\r\n$GatewayIpConfig2 = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig2 -SubnetId $Subnet2.Id -PublicIpAddressId $GatewayPublicIp2.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName2 -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig2 -GatewayType Vpn -VpnType RouteBased -GatewaySku Basic\r\n\r\n# Vnet\u9593\u63a5\u7d9a\u3092\u4f5c\u6210\r\n$VNetGateway1 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName1 -ResourceGroupName $ResourceGroupName\r\n$VNetGateway2 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName2 -ResourceGroupName $ResourceGroupName\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName1 -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway1 -VirtualNetworkGateway2 $VNetGateway2 -ConnectionType Vnet2Vnet -SharedKey $PreSharedKey\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName2 -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway2 -VirtualNetworkGateway2 $VNetGateway1 -ConnectionType Vnet2Vnet -SharedKey $PreSharedKey\r\n<\/pre>\n<h2>\u30b5\u30a4\u30c8\u9593 VPN \u3092\u4f7f\u7528\u3057\u305f Vnet2Vnet \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName1 = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d 1&gt;&quot;\r\n$VNetAddressPrefix1 = &quot;10.0.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix1 = &quot;10.0.0.0\/28&quot;\r\n$Subnet1AddressPrefix1 = &quot;10.0.1.0\/28&quot;\r\n$GatewayName1 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d 1&gt;&quot;\r\n$GatewayPublicIpName1 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d 1&gt;&quot;\r\n$LocalNetworkGatewayName2 = &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d 1&gt;&quot;\r\n$VNetName2 = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d 2&gt;&quot;\r\n$VNetAddressPrefix2 = &quot;10.1.0.0\/16&quot;\r\n$GatewaySubnetAddressPrefix2 = &quot;10.1.0.0\/28&quot;\r\n$Subnet1AddressPrefix2 = &quot;10.1.1.0\/28&quot;\r\n$GatewayName2 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d 2&gt;&quot;\r\n$GatewayPublicIpName2 = &quot;&lt;\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u540d 2&gt;&quot;\r\n$LocalNetworkGatewayName2 = &quot;&lt;\u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u540d 2&gt;&quot;\r\n$ConnectionName1 = &quot;&lt;\u63a5\u7d9a\u540d 1&gt;&quot;\r\n$ConnectionName2 = &quot;&lt;\u63a5\u7d9a\u540d 2&gt;&quot;\r\n$PreSharedKey = &quot;&lt;\u4e8b\u524d\u5171\u6709\u30ad\u30fc&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix1\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix1\r\nNew-AzureRmVirtualNetwork -Name $VNetName1 -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix1 -Subnet $Subnet1, $Subnet2\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -AddressPrefix $GatewaySubnetAddressPrefix2\r\n$Subnet2 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix2\r\nNew-AzureRmVirtualNetwork -Name $VNetName2 -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix2 -Subnet $Subnet1, $Subnet2\r\n\r\n# \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u7528\u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u30a2\u30c9\u30ec\u30b9\u3092\u4f5c\u6210\r\n$GatewayPublicIp1 = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName1 -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n$GatewayPublicIp2 = New-AzureRmPublicIpAddress -Name $GatewayPublicIpName2 -ResourceGroupName $ResourceGroupName -Location $Location -AllocationMethod Dynamic\r\n\r\n# \u4f5c\u6210\u3057\u305f\u30ea\u30bd\u30fc\u30b9\u3092\u6307\u5b9a\u3057\u3066\u3001\u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\n$Vnet1 = Get-AzureRmVirtualNetwork -Name $VNetName1 -ResourceGroupName $ResourceGroupName\r\n$Subnet1 = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet1\r\n$GatewayIpConfig1 = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig1 -SubnetId $Subnet1.Id -PublicIpAddressId $GatewayPublicIp1.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName1 -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig1 -GatewayType Vpn -VpnType RouteBased -GatewaySku Basic\r\n$Vnet2 = Get-AzureRmVirtualNetwork -Name $VNetName2 -ResourceGroupName $ResourceGroupName\r\n$Subnet2 = Get-AzureRmVirtualNetworkSubnetConfig -Name 'GatewaySubnet' -VirtualNetwork $Vnet2\r\n$GatewayIpConfig2 = New-AzureRmVirtualNetworkGatewayIpConfig -Name gwipconfig2 -SubnetId $Subnet2.Id -PublicIpAddressId $GatewayPublicIp2.Id \r\nNew-AzureRmVirtualNetworkGateway -Name $GatewayName2 -ResourceGroupName $ResourceGroupName -Location $Location -IpConfigurations $GatewayIpConfig2 -GatewayType Vpn -VpnType RouteBased -GatewaySku Basic\r\n\r\n# VPN Gateway \u306e\u30d1\u30d6\u30ea\u30c3\u30af IP \u3092\u53d6\u5f97 (\u3053\u3061\u3089\u3092\u30aa\u30f3\u30d7\u30ec\u30df\u30b9\u306e\u30eb\u30fc\u30bf\u30fc\u3067\u8a2d\u5b9a)\r\n$LocalNetworkGatewayIp1 = Get-AzureRmPublicIpAddress -Name $GatewayPublicIpName1 -ResourceGroupName $ResourceGroupName\r\n$LocalNetworkGatewayIp2 = Get-AzureRmPublicIpAddress -Name $GatewayPublicIpName2 -ResourceGroupName $ResourceGroupName\r\n\r\n# \u30ed\u30fc\u30ab\u30eb \u30cd\u30c3\u30c8\u30ef\u30fc\u30af \u30b2\u30fc\u30c8\u30a6\u30a7\u30a4\u3092\u4f5c\u6210\r\nNew-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName1 -ResourceGroupName $ResourceGroupName -Location $Location -GatewayIpAddress $LocalNetworkGatewayIp1 -AddressPrefix $VNetAddressPrefix2 \r\nNew-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName2 -ResourceGroupName $ResourceGroupName -Location $Location -GatewayIpAddress $LocalNetworkGatewayIp2 -AddressPrefix $VNetAddressPrefix1\r\n\r\n# Vnet\u9593\u63a5\u7d9a\u3092\u4f5c\u6210\r\n$VNetGateway1 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName1 -ResourceGroupName $ResourceGroupName\r\n$VNetGateway2 = Get-AzureRmVirtualNetworkGateway -Name $GatewayName2 -ResourceGroupName $ResourceGroupName\r\n$LocalNetworkGateway1 = Get-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName1 -ResourceGroupName $ResourceGroupName\r\n$LocalNetworkGateway2 = Get-AzureRmLocalNetworkGateway -Name $LocalNetworkGatewayName2 -ResourceGroupName $ResourceGroupName\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName1 -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway1 -LocalNetworkGateway2 $LocalNetworkGateway1 -ConnectionType IPsec -SharedKey $PreSharedKey\r\nNew-AzureRmVirtualNetworkGatewayConnection -Name $ConnectionName2 -ResourceGroupName $ResourceGroupName -Location $Location -VirtualNetworkGateway1 $VNetGateway2 -LocalNetworkGateway2 $LocalNetworkGateway2 -ConnectionType IPsec -SharedKey $PreSharedKey\r\n<\/pre>\n<h2>ARM \u540c\u58eb\u306e VNet Peering \u306e\u69cb\u7bc9<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName1 = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d 1&gt;&quot;\r\n$VNetAddressPrefix1 = &quot;10.0.0.0\/16&quot;\r\n$Subnet1AddressPrefix1 = &quot;10.0.0.0\/28&quot;\r\n$VNetName2 = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d 2&gt;&quot;\r\n$VNetAddressPrefix2 = &quot;10.1.0.0\/16&quot;\r\n$Subnet1AddressPrefix2 = &quot;10.1.0.0\/28&quot;\r\n$PeerName1 = &quot;&lt;\u30d4\u30a2\u30ea\u30f3\u30b0\u540d 1&gt;&quot;\r\n$PeerName2 = &quot;&lt;\u30d4\u30a2\u30ea\u30f3\u30b0\u540d 2&gt;&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix1\r\nNew-AzureRmVirtualNetwork -Name $VNetName1 -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix1 -Subnet $Subnet1\r\n$Subnet1 = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix2\r\nNew-AzureRmVirtualNetwork -Name $VNetName2 -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix2 -Subnet $Subnet1\r\n\r\n# \u4f5c\u6210\u3057\u305f VNet \u3092\u53d6\u5f97\r\n$VNet1 = Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName -Name $VNetName1\r\n$VNet2 = Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName -Name $VNetName2\r\n\r\n# VNetPeering \u3092\u4f5c\u6210\r\nAdd-AzureRmVirtualNetworkPeering -name $PeerName1 -VirtualNetwork $VNet1 -RemoteVirtualNetworkId $VNet2.id\r\nAdd-AzureRmVirtualNetworkPeering -name $PeerName2 -VirtualNetwork $VNet2 -RemoteVirtualNetworkId $VNet1.id\r\n<\/pre>\n<h2>ARM-ASM \u9593\u306e VNet Peering \u306e\u69cb\u7bc9 (\u540c\u4e00\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u306e\u307f)<\/h2>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3\u540d&gt;&quot;\r\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;\r\n$VNetName = &quot;shuda100709a&quot;\r\n$VNetAddressPrefix = &quot;10.0.0.0\/16&quot;\r\n$Subnet1AddressPrefix = &quot;10.0.0.0\/28&quot;\r\n$ClassicVNetId = &quot;&lt;\u30af\u30e9\u30b7\u30c3\u30af\u74b0\u5883\u306e VNet \u30ea\u30bd\u30fc\u30b9 Id&gt;&quot;\r\n$PeerName = &quot;shuda100709a2b&quot;\r\n\r\n# \u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210\r\nNew-AzureRmResourceGroup -Name $ResourceGroupName -Location $Location\r\n\r\n# \u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u30fb\u30b5\u30d6\u30cd\u30c3\u30c8\u3092\u4f5c\u6210\r\n$Subnet = New-AzureRmVirtualNetworkSubnetConfig -Name 'Subnet1' -AddressPrefix $Subnet1AddressPrefix\r\nNew-AzureRmVirtualNetwork -Name $VNetName -ResourceGroupName $ResourceGroupName -Location $Location -AddressPrefix $VNetAddressPrefix -Subnet $Subnet\r\n\r\n# \u4f5c\u6210\u3057\u305f VNet \u3092\u53d6\u5f97\r\n$VNet = Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName -Name $VNetName\r\n\r\n# VNetPeering \u3092\u4f5c\u6210\r\nAdd-AzureRmVirtualNetworkPeering -name $PeerName -VirtualNetwork $VNet -RemoteVirtualNetworkId $ClassicVNetId\r\n<\/pre>\n<h1><a name=\"Compute\"><\/a>2-4. Compute \u7cfb<\/h1>\n<h2>\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u306e\u4f5c\u6210\u30fb\u53d6\u5f97\u30fb\u524a\u9664 (ASM \u306e\u307f)<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n\r\nNew-AzureService -ServiceName &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot; -Location &quot;East Asia&quot;\r\n<\/pre>\n<h2>\u65e2\u5b58\u306e VHD \u3092\u30a4\u30e1\u30fc\u30b8\u3068\u3057\u3066\u95a2\u9023\u4ed8\u3051\u30fb\u524a\u9664 (ASM \u306e\u307f)<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\nAdd-AzureVMImage -ImageName &quot;&lt;\u30a4\u30e1\u30fc\u30b8\u540d&gt;&quot; -MediaLocation &quot;&lt;VHD \u30d1\u30b9&gt;&quot; -OS &quot;&lt;Windows \/ Linux&gt;&quot;\r\nRemove-AzureVMImage -ImageName &quot;&lt;\u30a4\u30e1\u30fc\u30b8\u540d&gt;&quot; # -DeleteVHD \u30aa\u30d7\u30b7\u30e7\u30f3\u3092\u4ed8\u4e0e\u3059\u308b\u3068 VHD \u3082\u524a\u9664\u53ef\u80fd\r\n<\/pre>\n<h2>OS \u30a4\u30e1\u30fc\u30b8\u306e\u53d6\u5f97<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n#ImageFamily \u4e00\u89a7\u306e\u53d6\u5f97\r\nGet-AzureVMImage | Select-Object ImageFamily -Unique | Sort-Object ImageFamily\r\n\r\n#ImageFamily \u3092\u3082\u3068\u306b\u6700\u65b0\u306e\u30a4\u30e1\u30fc\u30b8\u3092\u6307\u5b9a\r\n$Image = Get-AzureVMImage | Where-Object {$_.ImageFamily \u2013eq &quot;Windows Server 2012 R2 Datacenter&quot;}| Sort-Object PublishedDate -Descending | Select-Object -ExpandProperty ImageName -First 1\r\n\r\n########################################\r\n\r\n#\u4e00\u89a7\u304b\u3089\u30a4\u30e1\u30fc\u30b8\u3092\u624b\u52d5\u9078\u629e\r\n$ImageFamily = Get-AzureVMImage | Select-Object ImageFamily -Unique | Sort-Object ImageFamily | Out-GridView -Title &quot;Select OS Family&quot; -PassThru\r\n$Image = Get-AzureVMImage | Where-Object { $_.ImageFamily -eq $ImageFamily.ImageFamily } | Select-Object PublishedDate, OS, ImageFamily, Label, LogicalSizeInGB, ImageName | Sort-Object PublishedDate -Descending | Out-GridView -Title &quot;Select VM Image&quot; -PassThru\r\n<\/pre>\n<pre class=\"brush: powershell; title: ARM; notranslate\" title=\"ARM\">\r\n#ImagePublisher \u4e00\u89a7\u306e\u53d6\u5f97\r\nGet-AzureRmVMImagePublisher -Location &quot;East Asia&quot;\r\n\r\n#ImageOffer \u4e00\u89a7\u306e\u53d6\u5f97\r\nGet-AzureRmVMImageOffer -Location &quot;East Asia&quot; -PublisherName MicrosoftWindowsServer\r\n\r\n#ImageSku \u4e00\u89a7\u306e\u53d6\u5f97\r\nGet-AzureRmVMImageSku -Location &quot;East Asia&quot; -PublisherName MicrosoftWindowsServer -Offer WindowsServer\r\n\r\n#Image \u3092\u53d6\u5f97\r\nGet-AzureRmVMImage -Location &quot;East Asia&quot; -PublisherName MicrosoftWindowsServer -Offer WindowsServer -Skus 2012-Datacenter\r\n\r\n########################################\r\n\r\n#VM \u306e\u69cb\u6210\u60c5\u5831\u306b OS \u30a4\u30e1\u30fc\u30b8\u3092\u6307\u5b9a (\u8a73\u7d30\u306f\u5f8c\u8ff0)\r\n$VmConfig = Set-AzureRmVMSourceImage -VM $Vm -PublisherName &quot;OpenLogic&quot; -Offer &quot;CentOS&quot; -Skus &quot;6.7&quot; -Version &quot;latest&quot;\r\n<\/pre>\n<h2>\u30a4\u30e1\u30fc\u30b8\u304b\u3089 Windows \u4eee\u60f3\u30de\u30b7\u30f3\u306e\u4f5c\u6210<\/h2>\n<pre class=\"brush: powershell; title: ASM; notranslate\" title=\"ASM\">\r\n#\u8a2d\u5b9a\u9805\u76ee\r\n$SubscriptionId = &quot;&lt;\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3 ID&gt;&quot;\r\n$StorageAccountName = &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot;\r\n$ServiceName = &quot;&lt;\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u540d&gt;&quot;\r\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3&gt;&quot;\r\n$VmName = &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot;\r\n$VmSize = &quot;Standard_D1&quot;\r\n$ImageFamily = &quot;Windows Server 2012 R2 Datacenter&quot;\r\n\r\n#\u30ed\u30b0\u30a4\u30f3\u3001\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u6307\u5b9a (\u4e8b\u524d\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308c\u3070\u7701\u7565\u53ef\u80fd)\r\nAdd-AzureAccount\r\nSelect-AzureSubscription -SubscriptionId $SubscriptionId\r\n\r\n#\u30b9\u30c8\u30ec\u30fc\u30b8\u30a2\u30ab\u30a6\u30f3\u30c8\u306e\u4f5c\u6210\u3001\u6307\u5b9a (\u4e8b\u524d\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308c\u3070\u7701\u7565\u53ef\u80fd)\r\nNew-AzureStorageAccount -StorageAccountName $StorageAccountName -Location $Location -Type Standard_GRS\r\nSet-AzureSubscription \u2013SubscriptionId $SubscriptionId \u2013CurrentStorageAccountName $StorageAccountName\r\n\r\n#\u30e6\u30fc\u30b6\u30fc\u540d\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a\r\n$Credential = Get-Credential -Message &quot;Type the name and password of the local administrator account.&quot;\r\n \r\n#\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u8a2d\u5b9a\u3092\u5b9a\u7fa9\r\n$Image = Get-AzureVMImage | Where-Object {$_.ImageFamily \u2013eq $ImageFamily}| Sort-Object PublishedDate -Descending | Select-Object -ExpandProperty ImageName -First 1\r\n$VmConfig = New-AzureVMConfig -Name $VmName -InstanceSize $VmSize -ImageName $Image\r\n$VmConfig | Add-AzureProvisioningConfig -Windows -AdminUsername $Credential.UserName -Password $Credential.Password\r\n \r\n#\u30af\u30e9\u30a6\u30c9 \u30b5\u30fc\u30d3\u30b9\u3092\u4f5c\u6210\r\nNew-AzureService -ServiceName $ServiceName -Location $Location\r\n \r\n#\u4eee\u60f3\u30de\u30b7\u30f3\u3092\u4f5c\u6210\r\nNew-AzureVM \u2013ServiceName $ServiceName -VMs $VmConfig\r\n<\/pre>\n<p>&lt;# Public IP \u3092\u4ed8\u4e0e\u3057\u306a\u3044\u3068 RDP \u51fa\u6765\u306a\u3044\u306e\u3067\u3001\u8981\u8ffd\u52a0 (\u4ee5\u964d\u3059\u3079\u3066) #&gt;<\/p>\n<p>#\u8a2d\u5b9a\u9805\u76ee<br \/>\n$SubscriptionId = &quot;&lt;\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3 ID&gt;&quot;<br \/>\n$ResourceGroupName = &quot;&lt;\u30ea\u30bd\u30fc\u30b9\u30b0\u30eb\u30fc\u30d7\u540d&gt;&quot;<br \/>\n$StorageAccountName = &quot;&lt;\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u540d&gt;&quot;<br \/>\n$Location = &quot;&lt;\u30ea\u30fc\u30b8\u30e7\u30f3&gt;&quot;<br \/>\n$VmName = &quot;&lt;\u4eee\u60f3\u30de\u30b7\u30f3\u540d&gt;&quot;<br \/>\n$VmSize = &quot;Standard_D1&quot;<br \/>\n$VnetName = &quot;&lt;\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u540d&gt;&quot;<br \/>\n$SubnetName = &quot;&lt;\u30b5\u30d6\u30cd\u30c3\u30c8\u540d&gt;&quot;<br \/>\n$Nic1Name = &quot;&lt;NIC1 \u306e\u540d\u79f0&gt;&quot;<\/p>\n<p>#\u30ed\u30b0\u30a4\u30f3\u3001\u30b5\u30d6\u30b9\u30af\u30ea\u30d7\u30b7\u30e7\u30f3\u6307\u5b9a (\u4e8b\u524d\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308c\u3070\u7701\u7565\u53ef\u80fd)<br \/>\nLogin-AzureRmAccount<br \/>\nSelect-AzureRmSubscription -SubscriptionId $SubscriptionId<\/p>\n<p>#\u30e6\u30fc\u30b6\u30fc\u540d\u30fb\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u8a2d\u5b9a<br \/>\n$Credential = Get-Credential<\/p>\n<p>#\u30ea\u30bd\u30fc\u30b9 \u30b0\u30eb\u30fc\u30d7\u3092\u4f5c\u6210<br \/>\nNew-AzureRmResourceGroup \u2013Name $ResourceGroupName -Location $Location<\/p>\n<p>#\u30b9\u30c8\u30ec\u30fc\u30b8 \u30a2\u30ab\u30a6\u30f3\u30c8\u3092\u4f5c\u6210<br \/>\nNew-AzureRmStorageAccount \u2013StorageAccountName $StorageAccountName -Location &quot;East Asia&quot; -Type Standard_GRS \u2013ResourceGroupName $ResourceGroupName<br \/>\n$StorageAccount = Get-AzureRmStorageAccount -ResourceGroupName $ResourceGroupName -Name $StorageAccountName<\/p>\n<p>#\u4eee\u60f3\u30cd\u30c3\u30c8\u30ef\u30fc\u30af\u3092\u4f5c\u6210<br \/>\nNew-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName -Location &quot;East Asia&quot; -Name $VnetName -AddressPrefix &quot;192.168.0.0\/16&quot;<br \/>\n$Vnet = Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName -Name $VnetName<br \/>\nAdd-AzureRmVirtualNetworkSubnetConfig -Name $SubnetName -VirtualNetwork $Vnet -AddressPrefix &quot;192.168.1.0\/24&quot; |  Set-AzureRmVirtualNetwork<br \/>\n$Subnet = (Get-AzureRmVirtualNetwork -ResourceGroupName $ResourceGroupName -Name $VnetName).Subnets[0]<\/p>\n<p>#\u4eee\u60f3\u30de\u30b7\u30f3\u306e\u8a2d\u5b9a\u3092\u5b9a\u7fa9<br \/>\n$VmConfig = New-AzureRmVMConfig -Name $VmName -VMSize $VmSize<br \/>\n$VmConfig = Set-AzureRmVMOperatingSystem -VM $VmConfig -Windows -ComputerName $VmName -Credential $Credential<br \/>\n$VmConfig = Set-AzureRmVMSourceImage -PublisherName &quot;MicrosoftWindowsServer&quot; -Offer &quot;WindowsServer&quot; -Skus &quot;2012-R2-Datacenter&quot; -VM $VmConfig -Version <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Azure VM \u3092 PowerShell \u3067\u4f5c\u308b\u306b\u3042\u305f\u3063\u3066\u3001\u5143\u306b\u306a\u308b\u30b5\u30f3\u30d7\u30eb\u304c&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"https:\/\/www.syuheiuda.com\/?p=3489\">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":[39,31],"tags":[],"views":37350,"_links":{"self":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/3489"}],"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=3489"}],"version-history":[{"count":99,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/3489\/revisions"}],"predecessor-version":[{"id":5400,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=\/wp\/v2\/posts\/3489\/revisions\/5400"}],"wp:attachment":[{"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.syuheiuda.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}