%3CLINGO-SUB%20id%3D%22lingo-sub-336120%22%20slang%3D%22en-US%22%3EConfiguring%20Service%20Fabric%20security%20hardened%20cluster%20(ALB%20and%20ILB)%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-336120%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Feb%2015%2C%202017%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CP%3E%3CI%3E%20Authored%20by%20Marcin%20Kosieradzki%20%3C%2FI%3E%3C%2FP%3E%3CBR%20%2F%3E%20%3CEM%3E%20Special%20thanks%20to%20Chacko%20Daniel%20for%20helping%20out%20with%20the%20SFRP%20connectivity%20issue.%20%3C%2FEM%3E%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-1676162710%22%20id%3D%22toc-hId-1820203041%22%3EIntroduction%3C%2FH2%3E%3CBR%20%2F%3E%20Today%2C%20the%20default%20Service%20Fabric%20configuration%20exposes%20the%20ports%2019080%20and%2019000%20publicly.%20Those%20ports%20are%20usually%20protected%20by%20certificate-based%20security%20or%20AAD%2C%20but%20it%E2%80%99s%20definitely%20a%20good%20idea%20to%20hide%20those%20ports%20from%20the%20Internet.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20There%20are%20multiple%20ways%20to%20achieve%20this%20goal%3A%20%3CBR%20%2F%3E%3COL%3E%3CBR%20%2F%3E%3CLI%3EUsing%20Network%20Security%20Groups%20to%20limit%20traffic%20to%20selected%20public%20networks%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EExposing%20internal%20services%20using%20Internal%20Load%20Balancer%20to%26nbsp%3Ba%20private%20VNET%2C%20while%20still%20exposing%20public%20services%20with%20Azure%20Load%20Balancer%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EMore%20complex%20solutions%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FOL%3E%3CBR%20%2F%3E%20In%20this%20article%2C%20I%20will%20focus%20on%20the%20second%20approach.%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId--875994251%22%20id%3D%22toc-hId--731953920%22%3ENetwork%20Security%20Groups%3C%2FH2%3E%3CBR%20%2F%3E%20When%20starting%20with%20NSG%2C%26nbsp%3BI%20definitely%20recommend%26nbsp%3BChacko%20Daniel%E2%80%99s%20quick%20start%20template%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-quickstart-templates%2Ftree%2Fmaster%2Fservice-fabric-secure-nsg-cluster-65-node-3-nodetype%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2Fazure-quickstart-templates%2Ftree%2Fmaster%2Fservice-fabric-secure-nsg-cluster-65-node-3-nodetype%20%3C%2FA%3E.%20It%E2%80%99s%20quite%20complex%2C%20however%20it%20contains%20all%20the%20rules%20that%20are%20required%20for%20the%20Service%20Fabric%20cluster%20to%20work%2C%20and%20is%20well%20documented.%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-866816084%22%20id%3D%22toc-hId-1010856415%22%3EDual%20load%20balancer%20config%3C%2FH2%3E%3CBR%20%2F%3E%20This%20config%20requires%20to%20set%20up%20two%20load%20balancers%20using%20an%20ARM%20template%20to%20configure%20such%20a%20cluster.%20We%20will%20start%20with%20this%20basic%20template%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2FAzure%2Fazure-quickstart-templates%2Ftree%2Fmaster%2Fservice-fabric-secure-cluster-5-node-1-nodetype%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2FAzure%2Fazure-quickstart-templates%2Ftree%2Fmaster%2Fservice-fabric-secure-cluster-5-node-1-nodetype%20%3C%2FA%3E(it%20is%20also%20available%20from%20Azure%20SDK%20in%20Visual%20Studio).%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F73383i39458238B112CD3A%22%20%2F%3E%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EAzure%20Load%20Balancer%20will%20receive%20traffic%20on%20the%20public%20IP%20addresses%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EInternal%20Load%20Balancer%20will%20recieve%20traffic%20on%20the%20private%20VNET%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId--1881854382%22%20id%3D%22toc-hId--1737814051%22%3EImportant%3A%20Service%20Fabric%20Resource%20Provider%20(SFRP)%20integration%3C%2FH3%3E%3CBR%20%2F%3E%20There%20is%20a%20slight%20issue%20with%20this%20configuration%2C%20as%20for%20SF%20runtime%205.4%2C%20SFRP%20requires%20access%20to%20the%20SF%20endpoints%20and%20ports%2019000%20and%2019080%20for%20management%20purposes%20(and%20it%20is%20able%20to%20use%20only%20public%20addresses%20for%20that).%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20current%20VMSS%20implementation%20allows%20neither%20referencing%20a%20single%20port%20on%20two%20load%20balancers%2C%20nor%20configuring%20multiple%20IP%20configs%20per%20NIC%2C%20nor%20configuring%20multiple%20NICs%20per%20node.%20This%20makes%20exposing%20the%20single%20port%2019080%20for%20both%20load%20balancers%20virtually%20impossible.%20Even%20if%20possible%2C%20it%20would%20make%20the%20configuration%20much%20more%20complex%20and%20would%20require%20a%20Network%20Security%20Group.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Fortunately%2C%20this%20is%20no%20longer%20an%20issue%20in%205.5.%20Starting%20from%20this%20version%2C%20SF%20requires%20only%20an%20outbound%20connection%20to%20the%20SFRP%20https%3A%2F%2F%3CREGION%3E.servicefabric.azure.com%2Fruntime%2Fclusters%2F%2C%20which%20is%20provided%20by%20ALB%20to%20all%20the%20nodes.%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-57469458%22%20id%3D%22toc-hId-201509789%22%3EALB%20and%20ILB%20step-by-step%3C%2FH2%3E%3CBR%20%2F%3E%20Below%20is%20a%20short%20step-by-step%20guide.%20A%20lot%20of%20points%20in%20this%20guides%20apply%20also%20to%20configuring%20ALB%20and%20ILB%20for%20Virtual%20Machine%20Scale%20Sets%20without%20Service%20Fabric.%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId-1603766288%22%20id%3D%22toc-hId-1747806619%22%3EBasic%20cluster%20configuration%3C%2FH3%3E%3CBR%20%2F%3E%3COL%3E%3CBR%20%2F%3E%3CLI%3ECreate%20a%20project%20using%20the%20template%20service-fabric-secure-cluster-5-node-1-nodetype%20from%20the%20quickstart%20gallery.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EMake%20it%20running%20(you%20need%20to%20do%20the%20standard%20steps%20with%20Key%20Vault%20etc).%20It%20is%20a%20good%20idea%20to%20deploy%20it%20just%20to%20make%20sure%20the%20cluster%20is%20up%20and%20running%20%E2%80%93%20ILB%20can%20be%20added%20later%20on%20by%20redeploying%20a%20modified%20template.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FOL%3E%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId--948390673%22%20id%3D%22toc-hId--804350342%22%3EConfiguring%20ILB%20and%20ALB%3C%2FH3%3E%3CBR%20%2F%3E%20Now%20you%20need%20to%20create%20a%20secondary%20subnet%20in%20which%20your%20ILB%20will%20expose%20its%20front%20endpoint.%20In%20azuredeploy.json%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EStep%201%20%3C%2FSTRONG%3E.%20After%20the%20subnet0Ref%20variable%2C%20insert%20these%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%5D%20%3CBR%20%2F%3E%22subnet1Name%22%3A%20%22ServiceSubnet%22%2C%20%3CBR%20%2F%3E%22subnet1Prefix%22%3A%20%2210.0.1.0%2F24%22%2C%20%3CBR%20%2F%3E%22subnet1Ref%22%3A%20%22%5Bconcat(variables('vnetID')%2C'%2Fsubnets%2F'%2Cvariables('subnet1Name'))%5D%22%2C%20%3CBR%20%2F%3E%22ilbIPAddress%22%3A%20%2210.0.1.10%22%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EStep%202%20%3C%2FSTRONG%3E.%20Find%20where%20the%20virtual%20network%20is%20defined%20and%20add%20an%20additional%20subnet%20definition.%20You%20can%20deploy%20your%20template%20afterwards.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%5Bcode%20lang%3D%22js%22%20highlight%3D%229%2C10%2C11%22%5D%20%3CBR%20%2F%3E%22subnets%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22%5Bvariables('subnet0Name')%5D%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22addressPrefix%22%3A%20%22%5Bvariables('subnet0Prefix')%5D%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22%5Bvariables('subnet1Name')%5D%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22addressPrefix%22%3A%20%22%5Bvariables('subnet1Prefix')%5D%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%5D%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EStep%203%20%3C%2FSTRONG%3E.%20Now%20let's%20define%20variables%20for%20the%20ILB.%20After%20the%20lbNatPoolID0%20variable%2C%20insert%20new%20variables%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%5D%20%3CBR%20%2F%3E%22ilbID0%22%3A%20%22%5BresourceId('Microsoft.Network%2FloadBalancers'%2Cconcat('ILB'%2C'-'%2C%20parameters('clusterName')%2C'-'%2Cvariables('vmNodeType0Name')))%5D%22%2C%20%3CBR%20%2F%3E%22ilbIPConfig0%22%3A%20%22%5Bconcat(variables('ilbID0')%2C'%2FfrontendIPConfigurations%2FLoadBalancerIPConfig')%5D%22%2C%20%3CBR%20%2F%3E%22ilbPoolID0%22%3A%20%22%5Bconcat(variables('ilbID0')%2C'%2FbackendAddressPools%2FLoadBalancerBEAddressPool')%5D%22%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EStep%204%20%3C%2FSTRONG%3E.%20Now%20you%20can%20create%20the%20ILB.%20Find%20the%20section%20responsible%20for%20creating%20ALB%20-%20it%20has%20%22name%22%3A%20%22%5Bconcat('LB'%2C'-'%2C%20parameters('clusterName')%2C'-'%2Cvariables('vmNodeType0Name'))%5D%22%2C%20and%20after%20this%20entire%20large%20section%2C%20insert%20the%20ILB%20config%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20language%3D%22js%22%5D%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22apiVersion%22%3A%20%22%5Bvariables('lbApiVersion')%5D%22%2C%20%3CBR%20%2F%3E%22type%22%3A%20%22Microsoft.Network%2FloadBalancers%22%2C%20%3CBR%20%2F%3E%22name%22%3A%20%22%5Bconcat('ILB'%2C'-'%2C%20parameters('clusterName')%2C'-'%2Cvariables('vmNodeType0Name'))%5D%22%2C%20%3CBR%20%2F%3E%22location%22%3A%20%22%5Bvariables('computeLocation')%5D%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22frontendIPConfigurations%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22LoadBalancerIPConfig%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22privateIPAllocationMethod%22%3A%20%22Static%22%2C%20%3CBR%20%2F%3E%22subnet%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('subnet1Ref')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22privateIPAddress%22%3A%20%22%5Bvariables('ilbIPAddress')%5D%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%5D%2C%20%3CBR%20%2F%3E%22backendAddressPools%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22LoadBalancerBEAddressPool%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%7D%20%3CBR%20%2F%3E%7D%5D%2C%20%3CBR%20%2F%3E%22loadBalancingRules%22%3A%20%5B%5D%2C%20%3CBR%20%2F%3E%22probes%22%3A%20%5B%5D%2C%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22tags%22%3A%20%7B%20%3CBR%20%2F%3E%22resourceType%22%3A%20%22Service%20Fabric%22%2C%20%3CBR%20%2F%3E%22clusterName%22%3A%20%22%5Bparameters('clusterName')%5D%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20should%20now%20add%20reference%20to%20the%20Backend%20Address%20Pool%20of%20the%20fresh-configured%20ILB%20to%20the%20VMSS%20NIC%20configuration%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%20highlight%3D%225-7%22%5D%20%3CBR%20%2F%3E%22loadBalancerBackendAddressPools%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('lbPoolID0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('ilbPoolID0')%5D%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%5D%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20can%20deploy%20it%20and%20you%20have%20the%20ILB%20up%20and%20running%20along%20with%20ALB%2C%20but%20it%20has%20zero%20rules.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20At%20this%20point%2C%20you%20can%20reconfigure%20the%20ALB%20and%20the%20ILB%3A%20for%20example%2C%20you%20can%20move%20loadBalancingRules%20and%20probes%20for%2019000%20and%2019080%20ports%20to%20the%20ILB%20config%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3EStep%205%20%3C%2FSTRONG%3E.%20Move%20the%20loadBalancingRules%20and%20change%20ip%20pool%20references%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%20highlight%3D%222-39%22%5D%20%3CBR%20%2F%3E%22loadBalancingRules%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22LBRule%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22backendAddressPool%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('ilbPoolID0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22backendPort%22%3A%20%22%5Bvariables('nt0fabricTcpGatewayPort')%5D%22%2C%20%3CBR%20%2F%3E%22enableFloatingIP%22%3A%20%22false%22%2C%20%3CBR%20%2F%3E%22frontendIPConfiguration%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('ilbIPConfig0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22frontendPort%22%3A%20%22%5Bvariables('nt0fabricTcpGatewayPort')%5D%22%2C%20%3CBR%20%2F%3E%22idleTimeoutInMinutes%22%3A%20%225%22%2C%20%3CBR%20%2F%3E%22probe%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('lbProbeID0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22protocol%22%3A%20%22tcp%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22LBHttpRule%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22backendAddressPool%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('ilbPoolID0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22backendPort%22%3A%20%22%5Bvariables('nt0fabricHttpGatewayPort')%5D%22%2C%20%3CBR%20%2F%3E%22enableFloatingIP%22%3A%20%22false%22%2C%20%3CBR%20%2F%3E%22frontendIPConfiguration%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('ilbIPConfig0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22frontendPort%22%3A%20%22%5Bvariables('nt0fabricHttpGatewayPort')%5D%22%2C%20%3CBR%20%2F%3E%22idleTimeoutInMinutes%22%3A%20%225%22%2C%20%3CBR%20%2F%3E%22probe%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('lbHttpProbeID0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22protocol%22%3A%20%22tcp%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%5D%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3EAnd%20move%20the%20probes%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%20highlight%3D%222-19%22%5D%20%3CBR%20%2F%3E%22probes%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22FabricGatewayProbe%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22intervalInSeconds%22%3A%205%2C%20%3CBR%20%2F%3E%22numberOfProbes%22%3A%202%2C%20%3CBR%20%2F%3E%22port%22%3A%20%22%5Bvariables('nt0fabricTcpGatewayPort')%5D%22%2C%20%3CBR%20%2F%3E%22protocol%22%3A%20%22tcp%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22FabricHttpGatewayProbe%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22intervalInSeconds%22%3A%205%2C%20%3CBR%20%2F%3E%22numberOfProbes%22%3A%202%2C%20%3CBR%20%2F%3E%22port%22%3A%20%22%5Bvariables('nt0fabricHttpGatewayPort')%5D%22%2C%20%3CBR%20%2F%3E%22protocol%22%3A%20%22tcp%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%5D%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3EYou%20also%20need%20to%20update%20the%20probe%20variables%20to%20make%20them%20reference%20the%20ILB%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%5D%20%3CBR%20%2F%3E%22lbProbeID0%22%3A%20%22%5Bconcat(variables('ilbID0')%2C'%2Fprobes%2FFabricGatewayProbe')%5D%22%2C%20%3CBR%20%2F%3E%22lbHttpProbeID0%22%3A%20%22%5Bconcat(variables('ilbID0')%2C'%2Fprobes%2FFabricHttpGatewayProbe')%5D%22%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3EAt%20this%20point%2C%20you%20can%20deploy%20your%20template%2C%20and%20Service%20Fabric%20administrative%20endpoints%20are%20only%20available%20at%20your%20ILB%20IP%2010.0.1.10.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3EStep%206%20%3C%2FSTRONG%3E.%20It%20is%20also%20good%20idea%20to%20get%20rid%20of%20the%20rule%20allowing%20remote%20desktop%20access%20to%20your%20node%20cluster%20on%20its%20public%20IP%20(you%20can%20still%20access%20them%20from%20your%20internal%20network%20on%20addresses%20like%2010.0.0.4%2C%2010.0.0.5%2C%20etc.).%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20i)%20You%20need%20to%20delete%20it%20from%20the%20ALB%20configuration%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%20highlight%3D%222-13%22%5D%20%3CBR%20%2F%3E%22inboundNatPools%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22name%22%3A%20%22LoadBalancerBEAddressNatPool%22%2C%20%3CBR%20%2F%3E%22properties%22%3A%20%7B%20%3CBR%20%2F%3E%22backendPort%22%3A%20%223389%22%2C%20%3CBR%20%2F%3E%22frontendIPConfiguration%22%3A%20%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('lbIPConfig0')%5D%22%20%3CBR%20%2F%3E%7D%2C%20%3CBR%20%2F%3E%22frontendPortRangeEnd%22%3A%20%224500%22%2C%20%3CBR%20%2F%3E%22frontendPortRangeStart%22%3A%20%223389%22%2C%20%3CBR%20%2F%3E%22protocol%22%3A%20%22tcp%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%5D%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3Eii)%20And%20also%20from%20NIC%20IP%20Configuration%3A%20%3CBR%20%2F%3E%3CBR%20%2F%3E%5Bcode%20lang%3D%22js%22%20highlight%3D%222-4%22%5D%20%3CBR%20%2F%3E%22loadBalancerInboundNatPools%22%3A%20%5B%20%3CBR%20%2F%3E%7B%20%3CBR%20%2F%3E%22id%22%3A%20%22%5Bvariables('lbNatPoolID0')%5D%22%20%3CBR%20%2F%3E%7D%20%3CBR%20%2F%3E%5D%2C%20%3CBR%20%2F%3E%5B%2Fcode%5D%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3ENOTE%3A%20%3C%2FSTRONG%3EIf%20you%20have%20already%20deployed%20the%20template%2C%20you%20need%20to%20do%206ii%2C%20redeploy%20and%20then%206i.%20Otherwise%20you%20will%20get%20an%20error%3A%20LoadBalancerInboundNatPoolInUseByVirtualMachineScaleSet.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3EStep%207%20%3C%2FSTRONG%3E.%20Last%20thing%20%E2%80%93%20there%20is%20an%20option%20in%20the%20ARM%20template%20for%20Service%20Fabric%20called%20managementEndpoint%20%E2%80%93%20the%20best%20idea%20is%20to%20reconfigure%20it%20to%20the%20Fully%20Qualified%20Domain%20Name%20of%20your%20ILB%20IP%20Address.%20This%20option%20is%20related%20to%20the%20aforementioned%20SFRP-integration%20issue%20in%205.4%20and%20earlier.%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId-794419662%22%20id%3D%22toc-hId-938459993%22%3EWhat's%20next%3C%2FH3%3E%3CBR%20%2F%3E%20You%20can%20now%20freely%20configure%20all%20your%20services%20and%20decide%20which%20one%20is%20exposed%20on%20which%20load%20balancer.%20%3CBR%20%2F%3E%3CH3%20id%3D%22toc-hId--1757737299%22%20id%3D%22toc-hId--1613696968%22%3EComplete%20ARM%20template%3C%2FH3%3E%3CBR%20%2F%3E%20You%20can%20see%20the%20complete%20modified%20ARM%20template%20here%3A%20%3CA%20href%3D%22https%3A%2F%2Fgist.github.com%2Fmkosieradzki%2Fa892785483ec0f7a4c330f38c3d98be9%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgist.github.com%2Fmkosieradzki%2Fa892785483ec0f7a4c330f38c3d98be9%20%3C%2FA%3E.%20%3CBR%20%2F%3E%3CH2%20id%3D%22toc-hId-181586541%22%20id%3D%22toc-hId-325626872%22%3EMore%20complex%20scenarios%3C%2FH2%3E%3CBR%20%2F%3E%20There%20are%20many%20more%20complex%20solutions%20using%20multiple%20node%20types.%20For%20example%2C%20here's%20one%20described%20by%20Brent%20Stineman%3A%20%3CA%20href%3D%22https%3A%2F%2Fbrentdacodemonkey.wordpress.com%2F2016%2F08%2F01%2Fnetwork-isolationsecurity-with-azure-service-fabric%2F%22%20target%3D%22_blank%22%20rel%3D%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3Ehttps%3A%2F%2Fbrentdacodemonkey.wordpress.com%2F2016%2F08%2F01%2Fnetwork-isolationsecurity-with-azure-service-fabric%2F%20%3C%2FA%3E.%3C%2FREGION%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-336120%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Feb%2015%2C%202017%20Authored%20by%20Marcin%20KosieradzkiSpecial%20thanks%20to%20Chacko%20Daniel%20for%20helping%20out%20with%20the%20SFRP%20connectivity%20issue.%3C%2FLINGO-TEASER%3E%3C%2FLINGO-BODY%3E
Regular Visitor
First published on MSDN on Feb 15, 2017

Authored by Marcin Kosieradzki


Special thanks to Chacko Daniel for helping out with the SFRP connectivity issue.

Introduction


Today, the default Service Fabric configuration exposes the ports 19080 and 19000 publicly. Those ports are usually protected by certificate-based security or AAD, but it’s definitely a good idea to hide those ports from the Internet.

There are multiple ways to achieve this goal:

  1. Using Network Security Groups to limit traffic to selected public networks

  2. Exposing internal services using Internal Load Balancer to a private VNET, while still exposing public services with Azure Load Balancer

  3. More complex solutions


In this article, I will focus on the second approach.

Network Security Groups


When starting with NSG, I definitely recommend Chacko Daniel’s quick start template: https://github.com/Azure/azure-quickstart-templates/tree/master/service-fabric-secure-nsg-cluste... . It’s quite complex, however it contains all the rules that are required for the Service Fabric cluster to work, and is well documented.

Dual load balancer config


This config requires to set up two load balancers using an ARM template to configure such a cluster. We will start with this basic template: https://github.com/Azure/azure-quickstart-templates/tree/master/service-fabric-secure-cluster-5-... (it is also available from Azure SDK in Visual Studio).



  • Azure Load Balancer will receive traffic on the public IP addresses

  • Internal Load Balancer will recieve traffic on the private VNET


Important: Service Fabric Resource Provider (SFRP) integration


There is a slight issue with this configuration, as for SF runtime 5.4, SFRP requires access to the SF endpoints and ports 19000 and 19080 for management purposes (and it is able to use only public addresses for that).

The current VMSS implementation allows neither referencing a single port on two load balancers, nor configuring multiple IP configs per NIC, nor configuring multiple NICs per node. This makes exposing the single port 19080 for both load balancers virtually impossible. Even if possible, it would make the configuration much more complex and would require a Network Security Group.

Fortunately, this is no longer an issue in 5.5. Starting from this version, SF requires only an outbound connection to the SFRP https://<region>.servicefabric.azure.com/runtime/clusters/, which is provided by ALB to all the nodes.

ALB and ILB step-by-step


Below is a short step-by-step guide. A lot of points in this guides apply also to configuring ALB and ILB for Virtual Machine Scale Sets without Service Fabric.

Basic cluster configuration



  1. Create a project using the template service-fabric-secure-cluster-5-node-1-nodetype from the quickstart gallery.

  2. Make it running (you need to do the standard steps with Key Vault etc). It is a good idea to deploy it just to make sure the cluster is up and running – ILB can be added later on by redeploying a modified template.


Configuring ILB and ALB


Now you need to create a secondary subnet in which your ILB will expose its front endpoint. In azuredeploy.json:

Step 1 . After the subnet0Ref variable, insert these:

[code lang="js"]
"subnet1Name": "ServiceSubnet",
"subnet1Prefix": "10.0.1.0/24",
"subnet1Ref": "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]",
"ilbIPAddress": "10.0.1.10",
[/code]

Step 2 . Find where the virtual network is defined and add an additional subnet definition. You can deploy your template afterwards.

[code lang="js" highlight="9,10,11"]
"subnets": [
{
"name": "[variables('subnet0Name')]",
"properties": {
"addressPrefix": "[variables('subnet0Prefix')]"
}
},
{
"name": "[variables('subnet1Name')]",
"properties": {
"addressPrefix": "[variables('subnet1Prefix')]"
}
}]
[/code]

Step 3 . Now let's define variables for the ILB. After the lbNatPoolID0 variable, insert new variables:

[code lang="js"]
"ilbID0": "[resourceId('Microsoft.Network/loadBalancers',concat('ILB','-', parameters('clusterName'),'-',variables('vmNodeType0Name')))]",
"ilbIPConfig0": "[concat(variables('ilbID0'),'/frontendIPConfigurations/LoadBalancerIPConfig')]",
"ilbPoolID0": "[concat(variables('ilbID0'),'/backendAddressPools/LoadBalancerBEAddressPool')]",
[/code]

Step 4 . Now you can create the ILB. Find the section responsible for creating ALB - it has "name": "[concat('LB','-', parameters('clusterName'),'-',variables('vmNodeType0Name'))]", and after this entire large section, insert the ILB config:

[code language="js"]
{
"apiVersion": "[variables('lbApiVersion')]",
"type": "Microsoft.Network/loadBalancers",
"name": "[concat('ILB','-', parameters('clusterName'),'-',variables('vmNodeType0Name'))]",
"location": "[variables('computeLocation')]",
"properties": {
"frontendIPConfigurations": [
{
"name": "LoadBalancerIPConfig",
"properties": {
"privateIPAllocationMethod": "Static",
"subnet": {
"id": "[variables('subnet1Ref')]"
},
"privateIPAddress": "[variables('ilbIPAddress')]"
}
}],
"backendAddressPools": [
{
"name": "LoadBalancerBEAddressPool",
"properties": {}
}],
"loadBalancingRules": [],
"probes": [],
},
"tags": {
"resourceType": "Service Fabric",
"clusterName": "[parameters('clusterName')]"
}
},
[/code]

You should now add reference to the Backend Address Pool of the fresh-configured ILB to the VMSS NIC configuration:

[code lang="js" highlight="5-7"]
"loadBalancerBackendAddressPools": [
{
"id": "[variables('lbPoolID0')]"
},
{
"id": "[variables('ilbPoolID0')]"
}
],
[/code]

You can deploy it and you have the ILB up and running along with ALB, but it has zero rules.

At this point, you can reconfigure the ALB and the ILB: for example, you can move loadBalancingRules and probes for 19000 and 19080 ports to the ILB config:

Step 5 . Move the loadBalancingRules and change ip pool references:

[code lang="js" highlight="2-39"]
"loadBalancingRules": [
{
"name": "LBRule",
"properties": {
"backendAddressPool": {
"id": "[variables('ilbPoolID0')]"
},
"backendPort": "[variables('nt0fabricTcpGatewayPort')]",
"enableFloatingIP": "false",
"frontendIPConfiguration": {
"id": "[variables('ilbIPConfig0')]"
},
"frontendPort": "[variables('nt0fabricTcpGatewayPort')]",
"idleTimeoutInMinutes": "5",
"probe": {
"id": "[variables('lbProbeID0')]"
},
"protocol": "tcp"
}
},
{
"name": "LBHttpRule",
"properties": {
"backendAddressPool": {
"id": "[variables('ilbPoolID0')]"
},
"backendPort": "[variables('nt0fabricHttpGatewayPort')]",
"enableFloatingIP": "false",
"frontendIPConfiguration": {
"id": "[variables('ilbIPConfig0')]"
},
"frontendPort": "[variables('nt0fabricHttpGatewayPort')]",
"idleTimeoutInMinutes": "5",
"probe": {
"id": "[variables('lbHttpProbeID0')]"
},
"protocol": "tcp"
}
}
],
[/code]

And move the probes:

[code lang="js" highlight="2-19"]
"probes": [
{
"name": "FabricGatewayProbe",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": "[variables('nt0fabricTcpGatewayPort')]",
"protocol": "tcp"
}
},
{
"name": "FabricHttpGatewayProbe",
"properties": {
"intervalInSeconds": 5,
"numberOfProbes": 2,
"port": "[variables('nt0fabricHttpGatewayPort')]",
"protocol": "tcp"
}
}
],
[/code]

You also need to update the probe variables to make them reference the ILB:

[code lang="js"]
"lbProbeID0": "[concat(variables('ilbID0'),'/probes/FabricGatewayProbe')]",
"lbHttpProbeID0": "[concat(variables('ilbID0'),'/probes/FabricHttpGatewayProbe')]",
[/code]

At this point, you can deploy your template, and Service Fabric administrative endpoints are only available at your ILB IP 10.0.1.10.

Step 6 . It is also good idea to get rid of the rule allowing remote desktop access to your node cluster on its public IP (you can still access them from your internal network on addresses like 10.0.0.4, 10.0.0.5, etc.).

i) You need to delete it from the ALB configuration:

[code lang="js" highlight="2-13"]
"inboundNatPools": [
{
"name": "LoadBalancerBEAddressNatPool",
"properties": {
"backendPort": "3389",
"frontendIPConfiguration": {
"id": "[variables('lbIPConfig0')]"
},
"frontendPortRangeEnd": "4500",
"frontendPortRangeStart": "3389",
"protocol": "tcp"
}
}
]
[/code]

ii) And also from NIC IP Configuration:

[code lang="js" highlight="2-4"]
"loadBalancerInboundNatPools": [
{
"id": "[variables('lbNatPoolID0')]"
}
],
[/code]

NOTE: If you have already deployed the template, you need to do 6ii, redeploy and then 6i. Otherwise you will get an error: LoadBalancerInboundNatPoolInUseByVirtualMachineScaleSet.

Step 7 . Last thing – there is an option in the ARM template for Service Fabric called managementEndpoint – the best idea is to reconfigure it to the Fully Qualified Domain Name of your ILB IP Address. This option is related to the aforementioned SFRP-integration issue in 5.4 and earlier.

What's next


You can now freely configure all your services and decide which one is exposed on which load balancer.

Complete ARM template


You can see the complete modified ARM template here: https://gist.github.com/mkosieradzki/a892785483ec0f7a4c330f38c3d98be9 .

More complex scenarios


There are many more complex solutions using multiple node types. For example, here's one described by Brent Stineman: https://brentdacodemonkey.wordpress.com/2016/08/01/network-isolationsecurity-with-azure-service-... .