<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Hamza Junaid on Medium]]></title>
        <description><![CDATA[Stories by Hamza Junaid on Medium]]></description>
        <link>https://medium.com/@hamzajunaid?source=rss-711ba37d9cda------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*UlfT8Pa3nrrUdtbWhtakGg.jpeg</url>
            <title>Stories by Hamza Junaid on Medium</title>
            <link>https://medium.com/@hamzajunaid?source=rss-711ba37d9cda------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:32:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hamzajunaid/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Your Web App Doesn’t Handle HTTP Requests. Something Else Does.]]></title>
            <link>https://medium.com/@hamzajunaid/your-web-app-doesnt-handle-http-requests-something-else-does-00ea4e398727?source=rss-711ba37d9cda------2</link>
            <guid isPermaLink="false">https://medium.com/p/00ea4e398727</guid>
            <category><![CDATA[fastapi]]></category>
            <category><![CDATA[django]]></category>
            <category><![CDATA[web-server]]></category>
            <category><![CDATA[servers]]></category>
            <category><![CDATA[python-programming]]></category>
            <dc:creator><![CDATA[Hamza Junaid]]></dc:creator>
            <pubDate>Sat, 04 Jul 2026 21:17:51 GMT</pubDate>
            <atom:updated>2026-07-04T21:17:51.478Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Understanding the invisible system behind Django, FastAPI, and almost every backend framework.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mz2r0VAlbL2aRQHm1CaqZA.png" /></figure><p>Ask a room full of developers what happens when someone visits their website, and almost everyone says some version of the same thing: “my app runs, and it handles the request.”</p><p>It’s a small lie, repeated so often that nobody notices it anymore. Your application has never run on its own. Not once. It has never opened a socket, never read a byte off a network cable, never accepted a single visitor by itself. It has only ever been invoked, the same way a mailbox has never once walked outside to fetch its own mail. Once you see why that’s literally true, and not just a cute way of putting it, an entire stack of things you’ve probably treated as vaguely-understood magic (Gunicorn, Uvicorn, WSGI, ASGI, Nginx, your cloud provider’s mysterious “front end”) collapses into a small, precise set of ideas.</p><p>And here’s the part worth saying before we go further: none of this is a Python quirk. If you write Ruby, Java, Node, Go, or C#, the same architecture is running under your code too, under different names. The specifics below use Django and FastAPI as the running example, but stick around even if you’ve never opened either.</p><h4>Three actors, and only one of them is code you wrote</h4><p>Most of the confusion around this topic comes from treating “the server” as one blurry thing. In reality there are three separate actors involved in serving a single request, and mapping them to a postal system makes the split hard to un-see: a sorting facility that deals with the outside world, a carrier who does the actual walking, and a mailbox at the end of the route that never leaves its wall.</p><p><strong>The reverse proxy</strong> is the sorting facility. It sits at the edge of the network, facing the public internet directly. In a self-managed deployment this is Nginx. On a managed platform like Azure App Service, it’s a built-in front end (Application Request Routing, running on IIS) that does the same job without you provisioning anything.</p><p><strong>The application server</strong> is the carrier. It sits behind the proxy, facing your Python process, and its entire job is walking a properly formatted request the rest of the way to your code. This is Gunicorn or Uvicorn: a real, running program.</p><p><strong>The application</strong> is the mailbox: your Django project or FastAPI project, a single object loaded once into memory, that does nothing until something else invokes it.</p><p>The sorting facility and the carrier both know a great deal about networking and nothing about your business logic. The mailbox knows a great deal about your business logic and nothing about sockets or TCP. Keeping those two facts separate is most of what this article is about.</p><h4>The edge: what the sorting facility actually does</h4><p>A reverse proxy’s job is absorbing everything ugly about the open internet before any of it reaches your code, the same way a sorting facility filters and routes mail before a single letter ever reaches your street. Concretely, that means terminating TLS (doing the HTTPS handshake so your app never has to touch a certificate), load balancing across multiple backend instances if you’re running more than one, serving static files directly from disk without spinning up Python for a request that doesn’t need it, enforcing rate limits and request size caps, and buffering slow or misbehaving clients so a visitor on a bad connection can’t tie up a backend worker for the duration of their upload.</p><p>On Azure App Service, this entire layer is managed for you. The platform’s front end terminates HTTPS at the shared front ends, handles load balancing, and forwards a clean HTTP request to your container over the port you declare with the WEBSITES_PORT setting. You don&#39;t run Nginx yourself in that setup, and you generally shouldn&#39;t add a second one inside your container: the sorting facility already exists, you just don&#39;t see it.</p><h4>The application is a callable, and that word is doing real work</h4><p>Here’s the technical core of everything above. In Python, a callable is any object you can invoke with parentheses. Functions are callables. So are class instances that implement __call__:</p><pre>class Application:<br>    def __call__(self, environ, start_response):<br>        start_response(&quot;200 OK&quot;, [(&quot;Content-Type&quot;, &quot;text/plain&quot;)])<br>        return [b&quot;Hello&quot;]<br><br>app = Application()   # app(environ, start_response) now works</pre><p>When you write app = FastAPI(), or when Django builds its handler via get_wsgi_application(), you get back exactly this: an object sitting in memory, holding your routes and configuration, that can only do something when it is called. It cannot bind to a port. It cannot accept a connection. It cannot read a single byte off the network on its own initiative, no more than a mailbox can go stand at the sorting facility and demand its own mail. All it can do is: given the right input, in the right shape, produce the right output.</p><p>This is also the answer to a question that trips people up early: why can’t you just host Django directly, with nothing else involved? Because a callable has no way to receive anything, and a mailbox that nobody delivers to just sits there empty forever. Even python manage.py runserver, which looks like it&#39;s running your app with no other moving parts, is quietly running Django&#39;s own minimal WSGI server underneath, built on Python&#39;s standard library HTTP tooling. There is no version of this where &quot;just the app&quot; exists without some carrier, no matter how small, doing the actual walking.</p><h4>WSGI and ASGI: an address format, not a service</h4><p>If the application is just a callable waiting to be invoked, something has to define exactly what shape that callable must be, so that any carrier can deliver to any mailbox without custom integration work. That’s the entire purpose of WSGI and ASGI, and it’s the single most misunderstood fact in this whole area: <strong>WSGI and ASGI are not programs.</strong> You cannot run one. There is no wsgi process anywhere on your machine. They are written specifications, PEP 3333 for WSGI and its async successor for ASGI, defining a calling convention the way an addressing standard defines how a label must be written, nothing more.</p><p>WSGI’s contract: the application is a synchronous callable shaped like app(environ, start_response). environ is a plain dictionary carrying the parsed request (method, path, headers, a readable body stream). start_response is a callback you invoke to set the status line and headers before returning the response body as an iterable of bytes.</p><p>ASGI’s contract: the application is an async callable shaped like app(scope, receive, send). scope is a dictionary describing the connection and persists for its entire lifetime. receive and send are async callables used to exchange event-based messages rather than a single call-and-return, which is exactly what lets ASGI handle WebSockets, Server-Sent Events, and other long-lived connections that WSGI structurally cannot express.</p><p>Standardizing this calling convention is what decouples carriers from mailboxes. Without it, Gunicorn would need custom code for Django, separate custom code for Flask, and so on for every server-framework pair. With the standard in place, Gunicorn only needs to know how to call something shaped like (environ, start_response), and Django only needs to be something shaped that way. Neither needs to know the other exists, which is exactly why you can swap Gunicorn for uWSGI, or Django for Flask, without touching the other side of the equation.</p><h4>Gunicorn and Uvicorn: the ones who actually do the walking</h4><p>A specification has never opened a socket in its life, the same way an address format has never delivered a letter. Something has to implement it, and that something is Gunicorn (implementing WSGI) or Uvicorn (implementing ASGI). These are the carriers, real running processes, and their job covers everything a callable structurally cannot do: binding to a port, accepting TCP connections, parsing raw HTTP bytes into environ or scope, invoking the application per the spec, and writing the resulting bytes back to the client. They also own concurrency and process lifecycle: spawning worker processes or threads, restarting ones that crash, handling graceful reloads and OS signals.</p><p>Gunicorn’s sync workers are genuinely simple: one worker handles exactly one request at a time, start to finish, including every millisecond spent waiting on a database query or an external API call, the way a traditional carrier stands at one door until a reply is written before moving on. That worker is occupied the whole time even though it’s doing nothing but waiting. You scale this model by adding more workers, which is why Gunicorn’s own documentation recommends running it behind a reverse proxy in the first place: a single slow client trickling bytes over a bad connection could otherwise occupy a whole worker for far longer than the actual work requires.</p><p>Uvicorn runs an event loop instead, typically uvloop, a fast implementation built on libuv. A single loop can hold many requests concurrently, dropping off one and moving to the next the instant it would otherwise stand around waiting, then circling back the moment a reply is ready. This is precisely what makes async valuable for high-concurrency, I/O-heavy workloads: a service fanning out to several external APIs or LLM providers per request, for example, can have all of those calls in flight at once instead of queued behind each other.</p><p>The tradeoff worth remembering: the event loop only works if nothing running on it blocks. A synchronous database driver, a time.sleep, or a heavy CPU-bound loop called directly inside an async def handler freezes the entire loop, stalling every other in-flight request on that worker, not just the one that caused it, the equivalent of one slow resident jamming the carrier&#39;s whole delivery route. FastAPI has a specific mitigation here: a plain def route runs in an external threadpool automatically, while an async def route runs directly on the loop, meaning the non-blocking guarantee becomes your responsibility the moment you write async.</p><h4>Tracing one request end to end</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LJJI8sFHb8RqG4AG60TWVg.png" /></figure><p>Put every layer together and a request makes this exact trip, with the response retracing the same path in reverse:</p><ol><li>The browser resolves the domain, opens a TCP connection, negotiates TLS, and sends the raw HTTP request. It’s the letter leaving the sender’s hands.</li><li>The reverse proxy (Nginx, or the Azure App Service front end) terminates TLS, serves the request directly if it’s static, and forwards everything else to a backend instance.</li><li>The application server (Gunicorn or Uvicorn) accepts the connection and parses the request into environ or scope.</li><li>The application server invokes the application callable per the WSGI or ASGI contract. This is the exact boundary between generic infrastructure and your code, the moment the carrier hands the letter through the mail slot.</li><li>The framework (Django or FastAPI) wraps the parsed input into a request object.</li><li>Middleware runs: authentication, sessions, CSRF checks, logging.</li><li>The router matches the URL to your view or path operation, and your logic executes, often querying a database.</li><li>The response is built and passed back down through every layer above, in reverse, until it leaves as bytes on the wire.</li></ol><p>Nothing before step five has ever heard of your business logic. It behaves identically regardless of what you built. Everything from step five onward is the part that’s actually yours.</p><h4>The same pattern, under different names, everywhere else</h4><p>This shape, a sorting facility absorbing the internet’s chaos, a carrier implementing a calling convention, a mailbox waiting to be invoked, is not a Python invention. It shows up, independently, in nearly every backend ecosystem, because the underlying problem it solves (letting any carrier serve any mailbox) is universal.</p><p>Ruby has its own specification, Rack, playing the same role WSGI does, with Puma and Unicorn as the implementing servers. Java formalized the same idea decades earlier as the Servlet specification, with Tomcat and Jetty as containers, and the industry’s more recent shift from blocking Spring MVC to non-blocking, reactive Spring WebFlux mirrors the WSGI-to-ASGI transition almost exactly. Node.js never needed a separate specification, because its runtime is built around a single event loop by default, making every Node server structurally async from the start. Go sidesteps the sync/async split at the language level entirely, handing each incoming request its own lightweight, runtime-scheduled goroutine. Microsoft’s stack does it with Kestrel as the server and async/await woven through an ASP.NET Core middleware pipeline that behaves conceptually like ASGI&#39;s.</p><p>Different names, different decades, the same three-part shape every time.</p><h3>The one thing to keep</h3><p>Your code has never run by itself, and it never will. It waits. WSGI and ASGI are not machines; they’re the address format that lets a machine find it and hand it something correctly shaped. Gunicorn and Uvicorn are the carriers, the machines that actually do the delivering. Nginx, or your cloud platform’s front door, is the sorting facility, a separate machine again, standing between your mailbox and the internet’s chaos so your callable never has to face it directly.</p><p>Your app was never a mailman. It was always a mailbox, and now you know exactly who’s doing the walking, and what they’re carrying when they knock.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=00ea4e398727" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Moved an Azure Virtual Machine Between Resource Groups of different Subscriptions(Without…]]></title>
            <link>https://medium.com/@hamzajunaid/how-i-moved-an-azure-virtual-machine-between-resource-groups-of-different-subscriptions-without-f77b3a83f151?source=rss-711ba37d9cda------2</link>
            <guid isPermaLink="false">https://medium.com/p/f77b3a83f151</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[vm]]></category>
            <category><![CDATA[microsoft]]></category>
            <category><![CDATA[migration]]></category>
            <category><![CDATA[uptime]]></category>
            <dc:creator><![CDATA[Hamza Junaid]]></dc:creator>
            <pubDate>Sun, 19 Oct 2025 02:19:11 GMT</pubDate>
            <atom:updated>2025-10-19T02:26:11.087Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l_kfppcbQ988Ahjujuj18w.jpeg" /></figure><h3>How I Moved an Azure Virtual Machine Between Resource Groups of different Subscriptions(Without Downtime)</h3><p>During a recent cleanup of our Azure subscriptions, we realized that some of our Azure resources were residing in an old subscription. The challenge was that these services were operational and we had to migrate them to a new more managed subscription without causing disruptions. I was tasked to perform the migration of a resource group which contained a Virtual Machine and its dependent resources. I will discuss the process in this article.</p><h4><strong>Understanding Resource Moves in Azure</strong></h4><p>Azure provides a ‘move’ operation for its resources which takes care of the nitty gritty stuff of keeping the hardware consistent and all of that. They also have good <a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/move-resource-group-and-subscription">documentation</a> on how to perform migrations of different kinds of resources. Although guides exists but there are lots of limitations which makes this move a challenge to tackle.</p><h4>The Error I Encountered</h4><p>I went ahead with the <a href="https://learn.microsoft.com/en-us/azure/azure-resource-manager/management/move-resource-group-and-subscription?tabs=azure-cli#move-resources">documentation guide</a>. I was hoping to achieve it at one go but on one of the final stages Azure returned the following error:</p><pre>Move for resource type publicIPAddresses is not supported.<br>(Code: MoveNotSupported)</pre><p>This is a classic example of dependency when the parent resource depends on child resource which is not supported for the ‘move’ operation. My VM’s <strong>Public IP was dynamically allocated</strong>, and dynamic IPs cannot be moved between resource groups. In these type of situations there is not much you can do but to do work arounds to disconnect/remove the relationship b/w these resources before you can go ahead with the process.</p><h4>How I Fixed It</h4><p><strong>Step 1. </strong>Detach the old IP</p><ul><li>From the VM’s network interface → IP configurations → Unckeck the associate Public IP checkbox</li><li>(Don’t worry about losing access because the VM stays accessible via private IP inside VNet)</li><li>Note that detaching Public does not mean that VM will shut down any ongoing communications happening internally e.g. running programs etc.</li></ul><p><strong>Step 2</strong>: Perform the move once again</p><ul><li>This time without the public IP resource selected during the move. (we will later on delete it anyways from this old rg)</li><li>The move will take place and will take no more than 10 minutes. You will receive a notification saying the move was successful.</li></ul><p><strong>Step 3.</strong> Create a <strong>new Public IP</strong> in the target Resource Group</p><ul><li>The VM now resides in a new rg which does not contain an IP resource.</li><li>Go to NSG of the VM and under the same IP Configuration click the record of the IP (it will be showing static).</li><li>Select the checkbox of “Attach a dynamic IP”. It will auto create a new IP resource.</li><li>Click save.</li></ul><h4>Verification</h4><p>After the move:</p><ul><li>Check the VM is now listed in the new RG.</li><li>SSH using the new public IP to confirm connectivity:</li></ul><pre>ssh vm-user@&lt;new_public_ip&gt;</pre><ul><li>Delete unused resource of IP which still exists without any associations in old rg. Make sure to check the associations before deleting it. You can check it in the overview menu of IP.</li></ul><h4>Lessons Learned</h4><ul><li>Always review dependencies before moving resources.</li><li>Public IPs can’t be moved, especially if dynamically allocated.</li><li>Azure automatically moves child resources like disks and NICs.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f77b3a83f151" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>