Thursday, September 3, 2015

Block or Allow IP in Azure Cloud Service


To block or allow access of IP for your azure cloud service you need to write the following code in ServiceConfiguration.cscfg under </Role> tag:

<NetworkConfiguration>
    <AccessControls>
      <AccessControl name="test">
        <Rule action="permit" description="test" order="100" remoteSubnet="192.72.174.38/32" />
        <!--<Rule action="deny" description="test" order="200" remoteSubnet="0.0.0.0/0" />-->        
      </AccessControl>
    </AccessControls>
    <EndpointAcls>
      <EndpointAcl role="MyApp" endPoint="Endpoint1" accessControl="test"/>
    </EndpointAcls>
    <!--<AddressAssignments>
      <ReservedIPs>
        <ReservedIP name="YourStaticIP"/>
      </ReservedIPs>
    </AddressAssignments>-->
  </NetworkConfiguration>

Here I am allowing a specific IP and denying all IPs this is for my staging site.

Here "MyApp" - is my web role name
and "Endpoint1" - is my endpoint name as in csdef file.
In remoteSubnet="0.0.0.0/0" / section /0 is CIDR notation.

No comments:

Post a Comment