DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • How To Reduce the Impact of a Cloud Outage
  • CI/CD With Azure DevOps and Alibaba Cloud Kubernetes (ACK)
  • Azure Databricks: 14 Best Practices For a Developer
  • Building Hybrid Multi-Cloud Event Mesh With Apache Camel and Kubernetes

Trending

  • A Better Web3 Experience: Account Abstraction From Flow (Part 2)
  • Effective Tips for Debugging Complex Code in Java
  • Exploring Edge Computing: Delving Into Amazon and Facebook Use Cases
  • API Design
  1. DZone
  2. Software Design and Architecture
  3. Cloud Architecture
  4. Azure Service Fabric Cluster Behind A Firewall

Azure Service Fabric Cluster Behind A Firewall

Hanu Kommalapati user avatar by
Hanu Kommalapati
·
Jul. 09, 15 · Tutorial
Like (0)
Save
Tweet
Share
2.14K Views

Join the DZone community and get the full member experience.

Join For Free

Hosting a Service Fabric cluster on Azure for internet hosted clients requires it to be deployed behind a load balancer with public IP. By default the services will not have any network listeners configured; so, each service needs to implement its own listener by overriding CreateCommunicationListener() defined in StatefulServiceBase and StatelessServiceBase classes; the signature is shown below:

protected override ICommunicationListener CreateCommunicationListener() { ... } 

See Service Communications Model for guidance on implementing your own communications stack.

WcfCommunicationListner is provided by the Service Fabric SDK for hosting WCF endpoints inside stateful and stateless services. The usage of the listener is documented at WCF Communication Listener.

Current implementation of WcfCommunicationListener is not aware of the public IP address/FQDN; so, for NetTcpBinding it generates the following communication endpoint with private IP address:

net.tcp://10.0.0.5/7854ce3f-4e30-4949-b5e4-22cdcbd477c1/8f4106a5-0d38-4f30-aaf0-e435688e5ed6-130808019994632301 

This will work fine if the client also located in the same network; however, for internet based access the local IP address will have to be replaced with the load balancer's public IP/FQDN.

To fix this issue, I used the following listener implementation that extended WcfCommunicationListener:

 //WcfFabricCommunicationsListener.cs 
using Microsoft.ServiceFabric.Services.Wcf;
using System;
using System.Collections.Generic;  
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Fabric; 
using System.Threading; 
using System.ServiceModel; 
using System.ServiceModel.Description; 
public class WcfFabricCommunicationsListener: WcfCommunicationListener
{
  private string _gatewayFQDN;
  public WcfFabricCommunicationsListener(Type communicationInterfaceType, object service) : base(communicationInterfaceType, service) { }
  public WcfFabricCommunicationsListener(Type communicationInterfaceType, Type communicationImplementationType) : base(communicationInterfaceType, communicationImplementationType) { } 
  public override void Initialize(ServiceInitializationParameters serviceInitializationParameters) 
  { 
     ConfigurationPackage configPackage = serviceInitializationParameters.CodePackageActivationContext.GetConfigurationPackageObject("Config"); 
     var infrastructureSection = configPackage.Settings.Sections["Infrastructure"]; 
     _gatewayFQDN = infrastructureSection.Parameters["Gateway"].Value; 
     base.Initialize(serviceInitializationParameters); 
} 
public async override Task<string> OpenAsync(CancellationToken cancellationToken) 
{ 
  string partitionUrl = await base.OpenAsync(cancellationToken); 
  if (_gatewayFQDN == null) 
  { 
   return partitionUrl; 
  } 
  UriBuilder ub = new UriBuilder(partitionUrl); 
   ub.Host = _gatewayFQDN; 
   return ub.ToString(); 

  }
}

Initialize() expects the definition of the FQDN of the gateway through Config package as shown in the following snippet of Settings.xml: <!-- Settings.xml located in the Config directory of the service project --> 

<Settings> 
<!-- other stuff --> 
   <Section Name="Infrastructure"> 
   <Parameter Name="Gateway" Value="mycluster.cloudapp.net" /> 
  </Section> 
</Settings>

OpenAsync() merely replaces the host IP address with the FQDN of the load balancer.

cluster azure Firewall (computing)

Published at DZone with permission of Hanu Kommalapati, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How To Reduce the Impact of a Cloud Outage
  • CI/CD With Azure DevOps and Alibaba Cloud Kubernetes (ACK)
  • Azure Databricks: 14 Best Practices For a Developer
  • Building Hybrid Multi-Cloud Event Mesh With Apache Camel and Kubernetes

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: