Last-modified: 2016-06-24 (金) 02:23:00
Azure/Internal load balancer - Cloud Services構成をデプロイ(ASM)

概要

以下のような構成をデプロイします。
VNet [ Subnet [ InternalLoadBalancer - CloudServices(WebRole) ] ]

01.png

手順

  1. ポータルかAzure PowerShell&XML編集で、vnet1, Subnet-1を作成
  2. Visual StudioでCloud Service(WebRole)を作成
    言語は何でもいいですが、今回はnode.jsにしました
  3. ServiceConfiguration.Cloud.cscfgを編集
    NetworkConfiguration以下を追加します
    roleNameやVirtualNetworkSite/@name, Subnet/@nameは適宜調整してください
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
    
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
    <?xml version="1.0" encoding="utf-8"?>
    <ServiceConfiguration serviceName="AzureCloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2015-04.2.6">
      <Role name="WebRole1">
        <Instances count="1" />
        <ConfigurationSettings>
          <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
        </ConfigurationSettings>
      </Role>
      <NetworkConfiguration>
        <VirtualNetworkSite name="vnet1" />
        <AddressAssignments>
          <InstanceAddress roleName="WebRole1">
            <Subnets>
              <Subnet name="Subnet-1" />
            </Subnets>
          </InstanceAddress>
        </AddressAssignments>
        <LoadBalancers>
          <LoadBalancer name="ilb1">
            <FrontendIPConfiguration type="private" subnet="Subnet-1" />
          </LoadBalancer>
        </LoadBalancers>
      </NetworkConfiguration>
    </ServiceConfiguration>
  4. ServiceDefinition.csdefを編集
    InputEndpointをServiceConfiguration.Cloud.cscfgで定義したInternal load balancer(ILB)にします。
    EndpointをILBのみにすると、Public IPが割り当てられなくなります。
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
      9
     10
     11
     12
     13
     14
     15
     16
     17
     18
     19
     20
     21
     22
     23
     24
     25
     26
     27
     28
     29
    
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
     
    
    <?xml version="1.0" encoding="utf-8"?>
    <ServiceDefinition name="AzureCloudService1" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
     <WebRole name="WebRole1" vmsize="Small">
      <Sites>
       <Site name="Web">
        <Bindings>
         <Binding name="Endpoint1" endpointName="Endpoint1" />
        </Bindings>
       </Site>
      </Sites>
      <ConfigurationSettings>
       <Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
      </ConfigurationSettings>
      <Endpoints>
       <InputEndpoint loadBalancer="ilb1" name="Endpoint1" protocol="http" port="80"/>
      </Endpoints>
      <Startup>
       <Task commandLine="setup_web.cmd &gt; log.txt" executionContext="elevated" taskType="simple">
        <Environment>
         <Variable name="EMULATED">
          <RoleInstanceValue xpath="/RoleEnvironment/Deployment/@emulated" />
         </Variable>
         <Variable name="RUNTIMEID" value="node" />
         <Variable name="RUNTIMEURL" value="http://az413943.vo.msecnd.net/node/0.10.21.exe;http://nodertncu.blob.core.windows.net/iisnode/0.1.21.exe" />
        </Environment>
       </Task>
      </Startup>
     </WebRole>
    </ServiceDefinition>
  5. プロジェクトを右クリックし、[発行]
    [すべてのロールのリモートデスクトップを有効にする]に一度でもチェックをすると、GUIからは認証情報が消せなくなります。
    チェックをすると自動的にILB以外のendpointが設定されてしまうので、Public IPを割り当てたくない場合は絶対にチェックを入れてはいけません。
  6. 疎通確認用にVMをデプロイ
    Everything is expanded.Everything is shortened.
      1
      2
      3
      4
      5
      6
      7
      8
    
    -
    !
     
    -
    !
     
    -
    |
    
    # ログイン(ASM)
    Add-AzureAccount
     
    # 疎通確認用VMのデプロイ(参考 Azure/Load balancer - VM構成をデプロイ(ASM) を参照)
    ./deploy_vmv1.ps1 -SubscriptionName "無料試用版" -VNetName "vnet1" -SubnetName "Subnet-1" -CurrentStorageName "storage20160621000225" -CloudServiceName "sc20160621000225" -VMNames "vm0" -RDPPort 52200
     
    # Internal load balancerのIPは、ポータルで発行先のCloudServicesを選択し、[ダッシュボード]-[入力エンドポイント]欄で確認
    # vm0でIEを立ち上げ、http://<Internal load balancerのIP>で、発行したサイトが出れば成功
    

    以上で、Internal load balancer以下にCloudServices(WebRole)を閉じ込められました。

検証時の環境

参考