<p>I am trying to deploy an ASP.NET Core Web API service that receives messages in Service Bus using Docker / Azure Kubernetes, but am having trouble with the port blocked.</p>
<p>Here is my deployment files:</p>
<p><strong>Dockerfile</strong></p>
<pre><code>FROM mcr.microsoft.com/dotnet/aspnet:5.0 AS base
WORKDIR /app
EXPOSE 8004
EXPOSE 5671
EXPOSE 5672

ENV ASPNETCORE_URLS=http://+:8004 
ENTRYPOINT [&quot;dotnet&quot;, &quot;MyTest.dll&quot;]
</code></pre>
<p><strong>Deployment.yml</strong></p>
<p><a href="https://i.stack.imgur.com/DRFnb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DRFnb.png" alt="enter image description here" /></a></p>
<p><strong>Service.yaml</strong></p>
<p><a href="https://i.stack.imgur.com/EPIUW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EPIUW.png" alt="enter image description here" /></a></p>
<p>Seems it is all that is needed? But it still cannot access Service Bus.</p>

Water
<p>Thank you <a href="https://stackoverflow.com/users/10008173/david-maze">David Maze</a>. Posting your suggestion as an answer to help other community members.</p>
<blockquote>
<p>You seem to have included two PNG files in place of your YAML files. Those aren't searchable or runnable; <code>kubectl apply -f</code> will just complain if I try to run it</p>
</blockquote>
<blockquote>
<p>(If you're running the RabbitMQ broker in a separate StatefulSet, you don't need to declare anywhere that you're making outbound connections to it; you do not need Dockerfile <code>EXPOSE</code> directives or to mention port 5672 in the Kubernetes YAML anywhere.)</p>
</blockquote>
<p>You can refer to <a href="https://stackoverflow.com/questions/35397430/rabbitmq-cluster-setup-in-kubernetes">Rabbitmq cluster setup in Kubernetes</a></p>
