<?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 Dhiren Joshi on Medium]]></title>
        <description><![CDATA[Stories by Dhiren Joshi on Medium]]></description>
        <link>https://medium.com/@dhirenjoshi2003?source=rss-54738b91be11------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*q9zS9kBmqQMtZUN6</url>
            <title>Stories by Dhiren Joshi on Medium</title>
            <link>https://medium.com/@dhirenjoshi2003?source=rss-54738b91be11------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 13:30:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@dhirenjoshi2003/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[The Token Was Valid. The Gateway Said No.]]></title>
            <link>https://medium.com/@dhirenjoshi2003/the-token-was-valid-the-gateway-said-no-e076c7721d35?source=rss-54738b91be11------2</link>
            <guid isPermaLink="false">https://medium.com/p/e076c7721d35</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[enterprise-architecture]]></category>
            <dc:creator><![CDATA[Dhiren Joshi]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 22:16:29 GMT</pubDate>
            <atom:updated>2026-08-21T22:16:29.674Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a serverless fee management system on Azure, and the four hours I lost to a version number.</p><p>The token had a valid signature. The audience matched. The role claim was right there in the payload, in plain text, spelled correctly:</p><pre>&quot;roles&quot;: [&quot;FeeAdmin&quot;]</pre><p>API Management returned 401.</p><p>I spent the next forty minutes convinced I’d misconfigured the role. I hadn’t. The role was fine. The role had never been the problem.</p><p>But let me back up, because the JWT thing is the punchline and I’ve skipped the setup.</p><h3>What I was building</h3><p>A student fee management system. Nothing exotic — store fee records, expose an API so students can check their payment status, let administrators update records, and email anyone whose payment is overdue.</p><p>The interesting part isn’t the domain. It’s that I built it entirely serverless on Azure, and I wanted to see whether “serverless” actually means what the marketing says when you have to secure it properly.</p><p>Six services:</p><ul><li><strong>Azure Functions</strong> for the API and the fee logic</li><li><strong>Azure SQL</strong> for storage</li><li><strong>API Management</strong> as the gateway</li><li><strong>Entra ID</strong> for identity</li><li><strong>Logic Apps</strong> for the daily reminder job</li><li><strong>Application Insights</strong> for telemetry</li></ul><p>My background is AWS. Lambda, API Gateway, DynamoDB, Glue. So most of this was pattern-matching — Functions are Lambda, API Management is API Gateway, Logic Apps are roughly Step Functions. Entra ID is IAM if IAM had opinions.</p><p>Where Azure genuinely differs is that it pushes a lot more security into the gateway. In AWS you’d typically write a Lambda authoriser — actual code you deploy and maintain. In Azure, JWT validation is a chunk of XML you paste into a policy editor. No code, no deployment, no cold start.</p><p>I was sceptical. I’m less sceptical now, though we’ll get to why it took a while.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0pPgnYAbWYikl4Xi62Ckvg.png" /><figcaption>System Architecture</figcaption></figure><h3>The one design decision worth talking about</h3><p>Everything else in the system is unremarkable. Three endpoints, two tables, one scheduled job. But the authorisation model is the bit I’d defend.</p><p>There are two kinds of caller. Students read their own fee status. Administrators modify records. Those are very different privileges and they shouldn’t be gated by the same thing.</p><p>So: <strong>students need a subscription key. Administrators need a subscription key <em>plus</em> an Entra ID token carrying a specific role.</strong></p><p>Both checks happen at the gateway. Not in the Function — at the gateway, before the request touches compute. An unauthorised request never reaches my code at all, which means my code doesn’t need to defend against it.</p><p>And the Functions themselves are locked to AuthLevel.FUNCTION, so they require a key that only API Management holds. If someone finds the Function App&#39;s URL — and URLs leak, that&#39;s what URLs do — it&#39;s useless to them.</p><p>The practical upshot: if a subscription key leaks, someone can read fee statuses. Annoying. They cannot change anyone’s balance. That requires an identity that Entra has explicitly granted a role to.</p><p>That distinction is the whole point, and it took me about three attempts to get the policy scoping right, because my first instinct was to put the JWT check on the entire API. Which works beautifully, if you don’t mind students being unable to use the API.</p><h3>The bug</h3><p>Right. Back to the token.</p><p>To validate a JWT, API Management needs to know who issued it and how to verify the signature. You point it at an OpenID Connect discovery document — a standard URL that returns JSON describing the issuer, the algorithms, and where to find the public keys.</p><p>Mine pointed here:</p><pre>https://login.microsoftonline.com/{tenant}/v2.0/.well-known/openid-configuration</pre><p>Reasonable. It’s the current version. Why wouldn’t you use the current version.</p><p>The token I was sending had this in it:</p><pre>&quot;iss&quot;: &quot;https://sts.windows.net/{tenant}/&quot;,<br>&quot;ver&quot;: &quot;1.0&quot;</pre><p>Version 1.0. Issued by sts.windows.net, which is the old endpoint. And the v2.0 discovery document declares the issuer as login.microsoftonline.com/{tenant}/v2.0.</p><p>Different string. Validation fails. 401.</p><p>Not because the signature was wrong. Not because the audience didn’t match. Not because the role was missing. All three of those were fine. It failed on the issuer, which was the one field I hadn’t looked at, because why would you.</p><p>The reason it issues v1.0 tokens is that I used the client credentials flow with a .default scope, and that combination defaults to v1 unless you go and edit accessTokenAcceptedVersion in the app manifest. Nothing tells you this. Nothing warns you. The token just quietly comes back as v1 and everything downstream assumes you meant that.</p><p>The fix was deleting five characters:</p><pre>https://login.microsoftonline.com/{tenant}/.well-known/openid-configuration</pre><p>No /v2.0. Four hours, five characters.</p><p>The lesson isn’t “check the version.” The lesson is that I found it by <strong>decoding the token and reading it</strong>, which I should have done in minute five instead of minute two hundred. jwt.ms exists. It’s free. It takes eight seconds.</p><p>I had been changing things and re-testing. That’s not debugging, that’s gambling with extra steps.</p><h3>Other things that went wrong, briefly</h3><p><strong>pyodbc doesn’t talk to SQL Server.</strong> It talks to an ODBC driver that talks to SQL Server. pip install pyodbc succeeds happily on a machine with no driver installed, and then every connection fails with &quot;Data source name not found and no default driver specified,&quot; which is a sentence engineered to tell you nothing.</p><p><strong>Azure rejected my rate limiting policy.</strong> I’d used rate-limit-by-key with a counter-key expression, carefully written to count per subscription and fall back to IP. Very clever. Not supported on the Consumption tier:</p><pre>Policy is not allowed in &#39;Consumption&#39; sku</pre><p>Turns out plain rate-limit counts per subscription automatically, which is exactly what my clever expression was trying to do. I&#39;d written five lines to reproduce a default.</p><p><strong>A 500 with a zero-length body</strong>, which is the computing equivalent of a shrug. My PUT endpoint worked locally and failed through the gateway. The API Management test console doesn’t set Content-Type: application/json automatically, so req.get_json() raised, and the exception surfaced as a 500 instead of the 400 I&#39;d carefully written.</p><p><strong>My virtual environment lied to me.</strong> I ran pip install without activating it, so everything went to global Python. The Functions worker looks in .venv/Lib/site-packages, found nothing, and threw ModuleNotFoundError. The install had reported success. It had succeeded. Just somewhere else.</p><p><strong>The connection string ate itself.</strong> Azure’s template gives you Pwd={your_password_here}. I replaced the text and left the braces. In ODBC, braces are escaping syntax. In JSON, they&#39;re structure. The file became unparseable, which meant the Functions runtime couldn&#39;t read <em>any</em> setting from it — including the one telling it to use Python. The error was &quot;Worker runtime cannot be &#39;None&#39;&quot;, which is technically accurate and completely unhelpful, because the runtime setting was sitting right there on line five, perfectly visible, in a file nothing could parse.</p><h3>The one bit of code I actually like</h3><p>Partial updates. An admin sends you one field and you leave the rest alone.</p><p>The natural way to do this is to build the SQL at runtime:</p><pre>updates = []<br>if paid_amount is not None:<br>    updates.append(f&quot;PaidAmount = {paid_amount}&quot;)<br>if due_date is not None:<br>    updates.append(f&quot;DueDate = &#39;{due_date}&#39;&quot;)<br>sql = f&quot;UPDATE Students SET {&#39;, &#39;.join(updates)} WHERE StudentID = {student_id}&quot;</pre><p>That works. It’s also how SQL injection vulnerabilities get written, and it’s genuinely the first thing most people reach for, because the alternative isn’t obvious.</p><p>Here’s the alternative:</p><pre>UPDATE Students<br>SET TotalFee   = COALESCE(?, TotalFee),<br>    PaidAmount = COALESCE(?, PaidAmount),<br>    DueDate    = COALESCE(?, DueDate)<br>WHERE StudentID = ?</pre><p>COALESCE(a, b) returns the first non-null argument. Pass a value, the column updates. Pass null, the column gets written back to itself.</p><p>So sending {&quot;paidAmount&quot;: 95000} produces:</p><pre>SET TotalFee   = COALESCE(NULL,  TotalFee),    -- unchanged<br>    PaidAmount = COALESCE(95000, PaidAmount),  -- updated<br>    DueDate    = COALESCE(NULL,  DueDate)      -- unchanged</pre><p>Every column is written. Two of them to the value they already held. Net effect: exactly one field changed.</p><p>And the query text never varies. It’s fixed at the moment I typed it. There is no code path where user input becomes part of the SQL structure, because there’s no string building at all.</p><p>It’s not a clever trick. It’s a boring trick. But it turns a class of vulnerability into a non-issue, and I’d rather have boring and safe than clever and load-bearing.</p><h3>The thing that looked like a bug and wasn’t</h3><p>My reminder job sent eight emails. The overdue endpoint had returned nine students an hour earlier.</p><p>I assumed the loop was broken. Off-by-one somewhere, or the Logic App silently skipping an iteration.</p><p>It wasn’t. Earlier that day I’d tested the admin update endpoint by pushing student 16’s due date out to December. They weren’t overdue any more. The system had correctly excluded them.</p><p>Which is a small thing but it made me happy, because it meant the whole chain actually connected — the admin endpoint changed real state, the query reflected it, and the downstream job behaved accordingly. Three components agreeing without being told to.</p><p>Also a decent argument for making your seed script re-runnable. Mine starts with a DELETE, so resetting to a known state is one paste. Past me made that decision for tidiness. Present me was grateful for entirely different reasons.</p><h3>What I’d change</h3><p><strong>Managed identity for the database connection.</strong> I used a connection string with a password in an app setting. It’s not committed anywhere and it’s not in the repo, but it exists, and a credential that exists is a credential that can leak. Managed identity means there’s nothing to steal. I skipped it because it needs a contained database user and the failure mode is opaque, and I didn’t want to debug that under time pressure. That’s an honest reason, not a good one.</p><p><strong>An audit table.</strong> Right now the system records that a fee is 95,000. It doesn’t record who changed it, when, or what it was before. For financial data that’s a real gap. It would also give the Administrators table a genuine relationship to Students, which it currently lacks entirely — they&#39;re two tables sitting in the same database, politely ignoring each other.</p><p><strong>Optimistic concurrency.</strong> Two admins updating the same record simultaneously is last-write-wins. A RowVersion column surfaced as an ETag, with If-Match on the request and a 409 on conflict, would fix it. About twenty lines.</p><h3>Was serverless worth it?</h3><p>Mostly yes, with an asterisk.</p><p>The database is serverless and auto-pauses when idle. Costs nothing overnight. Also takes 30 to 60 seconds to wake up, which means the first request after a quiet period looks like a hang. Every subsequent one is instant.</p><p>That’s a real trade-off, not a flaw — I chose a tier that costs nothing when nobody’s using it, and the price is a cold start. For a fee system that gets checked a few times a day, that’s obviously correct. For anything latency-sensitive it would be obviously wrong.</p><p>The Function App has the same shape. Consumption plan, scales to zero, cold starts after about twenty minutes idle. My Logic App has exponential retry policies partly for genuine transient failures and partly because I knew the first call each morning would hit a cold Function and a paused database.</p><p>Which is the actual lesson, I think. Serverless doesn’t remove operational concerns. It swaps one set — patching, capacity, scaling — for another set — cold starts, per-invocation billing, and platform constraints you find out about when a policy editor tells you your SKU can’t do that.</p><p>I’d still pick it for this. But I’d pick it knowing what I was trading, rather than because the word sounds efficient.</p><p><em>Code’s on GitHub if you want to poke at it: </em><a href="https://github.com/dhiren-joshi/azure-fee-management-system"><em>github.com/dhiren-joshi/azure-fee-management-system</em></a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e076c7721d35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Built a ServerlessApp Without Losing My Mind (or Managing Servers)]]></title>
            <link>https://medium.com/@dhirenjoshi2003/how-i-built-a-serverlessapp-without-losing-my-mind-or-managing-servers-4bdc33941730?source=rss-54738b91be11------2</link>
            <guid isPermaLink="false">https://medium.com/p/4bdc33941730</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[serverless-architecture]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-serverless-services]]></category>
            <dc:creator><![CDATA[Dhiren Joshi]]></dc:creator>
            <pubDate>Wed, 14 May 2025 19:43:14 GMT</pubDate>
            <atom:updated>2025-05-14T19:43:14.175Z</atom:updated>
            <content:encoded><![CDATA[<p>Let me paint a picture. You’re trying to build a web app. But every guide starts with:</p><blockquote><em>“Step 1: Launch an EC2 instance.”</em></blockquote><p>Yikes.</p><p><strong>Good news?</strong> There’s a better way. It’s called <strong>serverless</strong>.</p><p>In this post, I’ll walk you through how I built a fully functional <strong>user registration system</strong> using AWS services — without managing a single server.</p><h3>🧠 What Even Is Serverless?</h3><p>Serverless means <em>you</em> don’t manage servers. The cloud provider (like AWS) handles all that complexity. You just focus on your code.</p><h3>Real World Analogy</h3><p>Think of it like Uber. You get a ride without owning or maintaining the car. Just tell it where to go.</p><p>Similarly, in serverless:</p><ul><li>You write code → AWS runs it</li><li>You store data → AWS manages the storage</li><li>You host frontend → AWS serves it</li></ul><h3>📦 Project Overview: What Are We Building?</h3><p>A simple yet scalable <strong>User Registration Web App</strong>:</p><ul><li><strong>Frontend</strong>: Collects name &amp; email from users</li><li><strong>Backend</strong>: A function that saves this data</li><li><strong>Database</strong>: Stores the registration info</li></ul><h3>Architecture Flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fFbR7hSEl9KGTQuHvjmDug.png" /><figcaption>🗺️ <strong>System Architecture — How All the AWS Services Talk to Each Other</strong></figcaption></figure><ul><li>User fills a form (HTML/JS)</li><li>Data sent via API Gateway</li><li>Lambda function triggered</li><li>Data saved to DynamoDB</li><li>Success message returned to frontend</li></ul><p>All hosted and served via AWS services.</p><h3>🧰 Tech Stack &amp; AWS Services (No Jargon, Just Vibes)</h3><p>Let’s break down what tools I used — and what they <em>actually</em> do:</p><h3>🖼️ Frontend</h3><p><strong>HTML/CSS/JavaScript</strong>: The classic trio. Used to build a simple registration form with some styling and interactivity.</p><p><strong>Amazon S3</strong>: Think of it like a Dropbox folder on steroids. It hosts your website files (HTML, CSS, JS).</p><p><strong>CloudFront</strong>: A speedy delivery guy. It serves your S3 content globally — fast and secure.</p><h3>🌐 API Handling</h3><p><strong>API Gateway</strong>: It’s like the receptionist at your backend’s office. It listens for requests (like form submissions) and routes them to the right function.<br><strong>Lambda</strong>: Your actual backend code lives here. No servers needed — just upload your code and AWS handles the rest.</p><h3>🗃️ Database</h3><p><strong>DynamoDB</strong>: A super fast, NoSQL database that stores the user info (name + email). It scales automatically and doesn’t need you to provision anything.</p><h3>🔐 Permissions &amp; Access</h3><p><strong>IAM (Identity and Access Management)</strong>: The bouncer at the club. It makes sure your Lambda can access DynamoDB (and nothing else unless allowed).</p><h3>🛠️ Let’s Build This — One AWS Service at a Time</h3><p>Now that you’ve got the dream and the diagram, let’s break it down like a cloud enthusiast on caffeine. ☕️</p><p><em>(No servers were harmed in the making of this app.)</em></p><p>We’ll build our registration app in <strong>five chill steps</strong>, each powered by a piece of AWS magic. ✨</p><h3>✅ Step 1: Frontend First — Let Users Type Stuff</h3><p>📁 <strong>Files</strong>: index.html, style.css, script.js</p><p><strong>What it does:</strong></p><ul><li>Shows a user-friendly form for name and email</li><li>Captures the data when submitted</li><li>Sends a request to the backend (our API endpoint)</li><li>Displays a success message (or cries if something breaks)</li></ul><p><strong>🧠 Logic in Simple Terms:</strong><br> User clicks <strong>Register</strong> → grab the name and email → send it to an API → wait for response → display result.</p><p>🪄 Think of this as the “face” of your app — users don’t care what’s running inside Lambda. They just want things to work.</p><h3>🧠 Step 2: Lambda — The Code That Actually Does Stuff</h3><p>📁 <strong>File</strong>: lambda_function.py</p><p><strong>What it does:</strong></p><ul><li>Receives the data sent by the frontend</li><li>Parses the JSON (gently, without yelling at it)</li><li>Stores the data in DynamoDB</li><li>Returns a friendly confirmation</li></ul><p><strong>🧠 Logic in Simple Terms:</strong><br> Read JSON → write data to DynamoDB → send back a happy message like “Registration successful!”</p><p>🍳 This is your invisible backend chef — flipping logic pancakes behind the scenes.</p><h3>🔐 Step 3: IAM — Giving Your Code the Keys to the Castle</h3><p>📁 <strong>No file — AWS Console setup</strong></p><p><strong>What it does:</strong></p><ul><li>Grants your Lambda function the permission to access DynamoDB</li><li>Prevents it from going rogue and accessing things it shouldn’t (like… your billing dashboard 😬)</li></ul><p><strong>🧠 Logic in Simple Terms:</strong><br> Create IAM Role → attach policies (AmazonDynamoDBFullAccess, AWSLambdaBasicExecutionRole) → assign to Lambda.</p><p>🚓 IAM is like the cloud’s security guard — strict but necessary.</p><h3>🚪 Step 4: API Gateway — Let the Web Talk to Your Lambda</h3><p>📁 <strong>No file — more AWS Console clicks</strong></p><p><strong>What it does:</strong></p><ul><li>Exposes a public endpoint (URL) to the outside world</li><li>Forwards any POST requests from users to the Lambda function</li><li>Converts HTTP requests into something Lambda can read and understand</li></ul><p><strong>🧠 Logic in Simple Terms:</strong><br> User submits form → API Gateway receives POST → forwards to Lambda → returns a response.</p><p>🧑‍💼 API Gateway is that helpful receptionist that routes all calls to the right person (without attitude).</p><h3>🌍 Step 5: Hosting the Frontend — Deploy Your Form to the World</h3><p>📁 <strong>Files from Step 1 deployed to AWS</strong></p><p><strong>What it does:</strong></p><ul><li>Stores your HTML/CSS/JS in an S3 bucket</li><li>CloudFront distributes the site via a CDN</li><li>Users can access your form from anywhere — lightning-fast</li></ul><p><strong>🧠 Logic in Simple Terms:</strong><br> Upload files to S3 → enable static hosting → connect CloudFront → users can visit your site.</p><p>🎉 Boom! Your frontend is live without spinning up a single server. Just vibes.</p><p>💻 <strong>Want to See the Full Code?</strong><br> I’ve open-sourced the complete project here 👉 <a href="https://github.com/dhiren-joshi/Serverless-Web-Application">GitHub: Serverless Web App Repo</a><br>Dive in, clone it, and start serverless-ing like a boss!</p><h3>🧪 Test It Out</h3><ul><li>Visit your site</li><li>Fill the form</li><li>Click Register</li><li>Check DynamoDB table</li></ul><p>🎉 User data saved without you lifting a single server!</p><h3>🧩 Want to Customize?</h3><ul><li>Add validation</li><li>Use Cognito for auth</li><li>Add email confirmations (SES)</li><li>Add analytics (Pinpoint)</li></ul><p>The sky’s the limit — and AWS owns the sky.</p><h3>📝 Final Thoughts</h3><p>Serverless made me feel like a frontend dev with backend superpowers. Here’s what I learned:</p><h3>Pros</h3><ul><li>No server headaches</li><li>Easy to scale</li><li>Pay only for what you use</li></ul><h3>Cons</h3><ul><li>IAM can be confusing</li><li>Debugging Lambda needs patience</li></ul><p>Still, I’ll take it over maintaining a server at 2 AM.</p><h3>🧠 TL;DR</h3><ul><li><strong>Frontend</strong>: HTML + JS hosted on S3</li><li><strong>Backend</strong>: Lambda function</li><li><strong>API</strong>: API Gateway</li><li><strong>Database</strong>: DynamoDB</li><li><strong>Deploy</strong>: Amplify / CloudFront</li></ul><p>No EC2s, no server configs, no stress.</p><h3>Liked this post?</h3><p>Clap, share, or drop a comment. I’ll be happy to answer questions, share the repo, or build memes around cloud confusion.</p><p>Cheers to building more and managing less! 🚀</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*53bbcjrzFbX1ZXPRZ5ZI9w.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*pAqPPcgx8RvgSBrBJwKIqQ.jpeg" /><figcaption>In the cloud, nobody can hear you scream… unless you forgot to provision enough resources.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4bdc33941730" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>