<?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 Theekshana Nirmal on Medium]]></title>
        <description><![CDATA[Stories by Theekshana Nirmal on Medium]]></description>
        <link>https://medium.com/@theek?source=rss-dbb05b840f5a------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*uKp9Kf5r58gBLMzN1ya8-g.jpeg</url>
            <title>Stories by Theekshana Nirmal on Medium</title>
            <link>https://medium.com/@theek?source=rss-dbb05b840f5a------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:54:32 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@theek/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[Build a Simple RAG System with LangChain in Under 100 Lines of TypeScript]]></title>
            <link>https://theek.medium.com/build-a-simple-rag-system-with-langchain-in-under-100-lines-of-typescript-5d0a4fc05c9a?source=rss-dbb05b840f5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d0a4fc05c9a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[rags]]></category>
            <category><![CDATA[retrieval-augmented-gen]]></category>
            <dc:creator><![CDATA[Theekshana Nirmal]]></dc:creator>
            <pubDate>Sat, 28 Mar 2026 18:46:28 GMT</pubDate>
            <atom:updated>2026-03-29T02:53:24.481Z</atom:updated>
            <content:encoded><![CDATA[<p>I tried building a simple chatbot that could answer questions using product documentation. My first idea was just to send the entire documentation with every question. It worked, but it was slow and expensive, and most of the text wasn’t even relevant. 😐</p><p>That’s when I found RAG (Retrieval-Augmented Generation). Instead of sending everything, you only send the small parts that are relevant to the question. The answers get better, and the cost drops.</p><p>To really understand it, I built a small project and used <a href="https://news.ycombinator.com/">Hacker News</a> as the data source. In this article, I’ll walk you through that step by step. It will pull today’s stories from that website and generate a summary focused on the topic of Artificial Intelligence.</p><p>And yes, in under 100 lines of TypeScript code 🙂</p><p><strong>GitHub Repository:</strong> <a href="https://github.com/theekshana-nirmal/hackernews-summarizer-rag.git">https://github.com/theekshana-nirmal/hackernews-summarizer-rag.git</a></p><p>Clone it if you want to follow along, or just use it as a reference.</p><h4>What We’re Building</h4><p>A small CLI tool that:</p><ul><li>Loads the front page of Hacker News</li><li>Splits the content into small pieces</li><li>Converts those pieces into vectors and stores them in memory</li><li>Builds a retrieval chain that finds the most relevant pieces for your question</li><li>Asks Google Gemini to answer based only on what it retrieved</li></ul><p>Think of it as a smart filter sitting between raw content and your question.</p><h4>The RAG Pipeline</h4><p>Before we write any code, it helps to see the full picture of what we are building.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*j_g-PuYcz0fENcSbmzQo7g.png" /><figcaption>The RAG Pipeline</figcaption></figure><p>Every RAG system follows roughly these same five steps. This project is a clean, minimal version of that pipeline so you can see each step working.</p><h4>Tech Stack</h4><ul><li><strong>TypeScript:</strong> Clean, typed, predictable. Makes things easier as the project grows.</li><li><strong>LangChain:</strong> Saves you from wiring everything manually. You get loaders, splitters, embeddings, and chains out of the box.</li><li><strong>Google Gemini API:</strong> Used for both embeddings and answers. Fast and easy to get started with via a free API key. (<a href="https://aistudio.google.com/api-keys">https://aistudio.google.com</a>)</li><li><strong>dotenv:</strong> Keeps your API key out of your codebase.</li></ul><figure><img alt="You can get your free Google Gemini API key from https://aistudio.google.com/api-keys" src="https://cdn-images-1.medium.com/max/1024/1*UDDxetQNPlFpaDvIJryQWA.png" /><figcaption>You can get your free Google Gemini API key from <a href="https://aistudio.google.com/api-keys">https://aistudio.google.com/api-keys</a></figcaption></figure><h3>Step-by-Step</h3><h4>Step 0: Project Setup</h4><p>Create a new folder and initialise it</p><pre>mkdir hackernews-summarizer-rag<br>cd hackernews-summarizer-rag<br>npm init -y</pre><p>Install dependencies:</p><pre>npm install @langchain/community @langchain/core @langchain/google-genai @langchain/textsplitters langchain cheerio dotenv<br>npm install -D typescript ts-node</pre><p>Create a tsconfig.json file:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;ESNext&quot;,<br>    &quot;module&quot;: &quot;NodeNext&quot;,<br>    &quot;moduleResolution&quot;: &quot;NodeNext&quot;,<br>    &quot;moduleDetection&quot;: &quot;force&quot;,<br>    &quot;strict&quot;: true,<br>    &quot;esModuleInterop&quot;: true,<br>    &quot;skipLibCheck&quot;: true,<br>    &quot;outDir&quot;: &quot;./dist&quot;<br>  },<br>  &quot;include&quot;: [<br>    &quot;*/.ts&quot;,<br>    &quot;.env&quot;<br>  ]<br>}</pre><p>Create a .env file in the root:</p><pre>GOOGLE_API_KEY=your_api_key_here</pre><p>You can get a free API key from <a href="https://aistudio.google.com/">Google AI Studio</a>.</p><p>Now, create an index.ts file and add the entry point:</p><pre>import &quot;dotenv/config&quot;;<br><br>async function main() {<br>  // we&#39;ll build this step by step (your code goes here)<br>}<br>main();</pre><p>Run it to confirm everything works:</p><pre>npx ts-node - esm index.ts</pre><p>You should see no errors. Now we build the pipeline, one step at a time.</p><h4>Step 1: Load the Web Page</h4><p>In this step, we fetch the Hacker News front page and pull only the story titles. We do not need the whole HTML, just the headlines.</p><p>Install nothing new. Add this import and code inside main():</p><pre>import &quot;dotenv/config&quot;;<br><br>// New<br>import { CheerioWebBaseLoader } from &quot;@langchain/community/document_loaders/web/cheerio&quot;;<br><br>async function main() {<br>  // STEP 01: Load the Web Page<br>  const loader = new CheerioWebBaseLoader(&quot;https://news.ycombinator.com/&quot;, {<br>    selector: &quot;.titleline&quot;,<br>  });<br>  const docs = await loader.load();<br>  console.log(docs[0].pageContent);<br>}<br><br>main();</pre><p>CheerioWebBaseLoader makes an HTTP request to the URL, parses the HTML, and uses the CSS selector .titleline to extract only the story title elements. The result is an array of Document objects, each containing a pageContent string and some metadata like the source URL.</p><p>The selector option is what keeps this focused. Without it, you would get the entire raw HTML of the page. That .titleline class is specific to Hacker News’s markup. If you ever load a different site, you would inspect the page and find the relevant selector there.</p><p><strong>Alternatives:</strong> <em>LangChain</em> also provides PuppeteerWebBaseLoader for pages that require JavaScript to render, and PlaywrightWebBaseLoader as another option. For static pages like Hacker News, <em>Cheerio</em> is faster and simpler.</p><p>(FYI) You can refer <em>LangChain</em> Document Loaders section of the documentation for more information:<strong> </strong><a href="https://docs.langchain.com/oss/javascript/integrations/document_loaders/web_loaders">https://docs.langchain.com/oss/javascript/integrations/document_loaders/web_loaders</a></p><h4>Step 2: Split into Chunks</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qCiqiG-kIW2KoxeYF2BKhA.png" /><figcaption>Split into Chunks</figcaption></figure><p>The full page content is one long string. Language models and vector search work better when content is broken into smaller, focused pieces. That is what this step does.</p><pre>import &quot;dotenv/config&quot;;<br>import { CheerioWebBaseLoader } from &quot;@langchain/community/document_loaders/web/cheerio&quot;;<br><br>//New<br>import { RecursiveCharacterTextSplitter } from &quot;@langchain/textsplitters&quot;;<br><br>async function main() {<br>  // STEP 01 Code...<br>  // STEP 02: Split into Chunks<br>  const splitter = new RecursiveCharacterTextSplitter({<br>    chunkSize: 150,<br>    chunkOverlap: 15,<br>  });<br>  const chunks = await splitter.splitDocuments(docs);<br>  console.log(chunks);<br>}<br><br>main();</pre><p>RecursiveCharacterTextSplitter cuts the document into pieces no longer than chunkSizecharacters. The chunkOverlap setting means each chunk shares 15 characters with the next one. This overlap prevents a sentence from being cut right in the middle and lost between two chunks.</p><p>chunkSize: 150 is small because each Hacker News story title is short. If you were chunking a long article or a PDF, you would use something like 500 to 1000. The right size depends on the content.</p><p><strong>Alternatives:</strong> <em>LangChain</em> also has TokenTextSplitter If you want to split by token count instead of character count, and MarkdownTextSplitter for structured markdown documents.</p><p>(FYI) You can refer to <em>LangChain</em> Text splitter integrations documentation for more information: <a href="https://docs.langchain.com/oss/javascript/integrations/splitters">https://docs.langchain.com/oss/javascript/integrations/splitters</a></p><h4>Step 3: Create Embeddings + Store Them</h4><p>This is where the “retrieval” part of RAG gets set up. We convert each chunk into a vector, which is a list of numbers that represents the meaning of the text. Then we store all those vectors in memory so we can search them later.</p><pre>import &quot;dotenv/config&quot;;<br>import { CheerioWebBaseLoader } from &quot;@langchain/community/document_loaders/web/cheerio&quot;;<br>import { RecursiveCharacterTextSplitter } from &quot;@langchain/textsplitters&quot;;<br><br>//New<br>import { GoogleGenerativeAIEmbeddings } from &quot;@langchain/google-genai&quot;;<br>import { MemoryVectorStore } from &quot;@langchain/classic/vectorstores/memory&quot;;<br><br>async function main() {<br>  // STEP 01 Code...<br>  // STEP 02 Code...<br>  // STEP 03: Create Embeddings + Store Them<br>  const embeddings = new GoogleGenerativeAIEmbeddings({<br>    modelName: &quot;gemini-embedding-001&quot;,<br>  });<br>  const vectorStore = await MemoryVectorStore.fromDocuments(chunks, embeddings);<br>  console.log(&quot;Vector store ready.&quot;);<br>}<br><br>main();</pre><p>MemoryVectorStore.fromDocuments takes every chunk, sends it to the Gemini embedding model, gets back a vector for each one, and stores all of them in memory. When you later search for chunks related to a question, this store compares your question’s vector against all the stored vectors and returns the closest matches.</p><p>gemini-embedding-001 converts text to a high-dimensional vector. Two pieces of text with similar meaning will have vectors that are numerically close to each other. This is what makes semantic search work.</p><p><strong>Alternatives:</strong> For a production system, you would replace MemoryVectorStore with a persistent vector database. Popular options include <a href="https://docs.pinecone.io/guides/get-started/overview"><em>Pinecone</em></a><em>, </em><a href="https://supabase.com/docs"><em>Supabase</em></a><em> with </em><a href="https://supabase.com/docs/guides/database/extensions/pgvector"><em>pgvector</em></a><em>, </em><a href="https://docs.weaviate.io/weaviate"><em>Weaviate</em></a><em>, and </em><a href="https://docs.trychroma.com/docs/overview/introduction"><em>Chroma</em></a><em>.</em> LangChain has built-in support for all of them, so swapping is mostly just changing the import and connection setup. For embeddings, you could also use OpenAI’s text-embedding-3-small or a local model via Ollama.</p><h4>Step 4: Build the Retrieval Chain</h4><p>Now we connect the vector store to the language model. This step sets up the full pipeline, a retriever that finds relevant chunks, a prompt that puts them into context, and a chain that sends everything to Gemini and gets an answer back.</p><pre>import &quot;dotenv/config&quot;;<br>import { CheerioWebBaseLoader } from &quot;@langchain/community/document_loaders/web/cheerio&quot;;<br>import { RecursiveCharacterTextSplitter } from &quot;@langchain/textsplitters&quot;;<br>import { GoogleGenerativeAIEmbeddings } from &quot;@langchain/google-genai&quot;;<br>import { MemoryVectorStore } from &quot;@langchain/classic/vectorstores/memory&quot;;<br><br>// New<br>import { ChatGoogleGenerativeAI } from &quot;@langchain/google-genai&quot;;<br>import { createRetrievalChain } from &quot;@langchain/classic/chains/retrieval&quot;;<br>import { createStuffDocumentsChain } from &quot;@langchain/classic/chains/combine_documents&quot;;<br>import { ChatPromptTemplate } from &quot;@langchain/core/prompts&quot;;<br><br>async function main() {<br>  // STEP 01 Code...<br>  // STEP 02 Code...<br>  // STEP 03 Code...<br>  // STEP 04: Build the Retrieval Chain<br>  const model = new ChatGoogleGenerativeAI({<br>    model: &quot;gemini-2.5-flash&quot;,<br>    temperature: 0.3,<br>  });<br>  const prompt = ChatPromptTemplate.fromTemplate(`<br>You are a news summarizer. Use ONLY the context below.<br>Context: {context}<br>Question: {input}<br>`);<br>  const combineDocsChain = await createStuffDocumentsChain({<br>    llm: model,<br>    prompt,<br>  });<br>  const ragChain = await createRetrievalChain({<br>    retriever: vectorStore.asRetriever({ k: 3 }),<br>    combineDocsChain,<br>  });<br>}<br><br>main();</pre><p>Three things are happening here.</p><ul><li>First, ChatGoogleGenerativeAI sets up the Gemini model. The temperature: 0.3 keeps the output focused and factual rather than creative.</li><li>Second, the ChatPromptTemplate defines how we talk to the model. The {context} placeholder will be filled with the retrieved chunks and {input} will be your question. The instruction “Based ONLY on the context” is important. It stops the model from pulling in things it learned during training.</li><li>Third, createRetrievalChain wires the retriever and the chain together. The k: 3 in asRetriever({k: 3}) means it will fetch the three most relevant chunks to answer any question.</li></ul><p><strong>Alternatives: </strong>createStuffDocumentsChain puts all retrieved documents directly into the prompt. For large documents, you might use createMapReduceDocumentsChain instead, which processes each document separately and then combines results. For the model, you could swap Gemini for OpenAI’s gpt-4o or a local model through Ollama.</p><h4>Step 5: Ask a Question</h4><p>The pipeline is ready. Now we invoke it with a question.</p><pre>import &quot;dotenv/config&quot;;<br>import { CheerioWebBaseLoader } from &quot;@langchain/community/document_loaders/web/cheerio&quot;;<br>import { RecursiveCharacterTextSplitter } from &quot;@langchain/textsplitters&quot;;<br>import { GoogleGenerativeAIEmbeddings } from &quot;@langchain/google-genai&quot;;<br>import { MemoryVectorStore } from &quot;@langchain/classic/vectorstores/memory&quot;;<br>import { ChatGoogleGenerativeAI } from &quot;@langchain/google-genai&quot;;<br>import { createRetrievalChain } from &quot;@langchain/classic/chains/retrieval&quot;;<br>import { createStuffDocumentsChain } from &quot;@langchain/classic/chains/combine_documents&quot;;<br>import { ChatPromptTemplate } from &quot;@langchain/core/prompts&quot;;<br><br>async function main() {<br>  // STEP 01 Code...<br>  // STEP 02 Code...<br>  // STEP 03 Code...<br>  // STEP 04 Code...<br>  // STEP 05: Ask a Question<br>  const result = await ragChain.invoke({<br>    input: &quot;What are the main AI-related news stories today?&quot;,<br>  });<br><br>  console.log(&quot;\n - - SUMMARY - -\n&quot;);<br>  console.log(result.answer);<br>}<br><br>main();</pre><p>ragChain.invoke takes your question, runs it through the retriever to fetch the top 3 matching chunks from <em>Hacker News</em>, builds the final prompt with those chunks as context, sends it to Gemini, and returns the answer. The answer lives in result.answer.</p><p>That’s it. You now have a working RAG system.</p><h4>Full Code</h4><pre>import &quot;dotenv/config&quot;;<br>import { CheerioWebBaseLoader } from &quot;@langchain/community/document_loaders/web/cheerio&quot;;<br>import { RecursiveCharacterTextSplitter } from &quot;@langchain/textsplitters&quot;;<br>import { GoogleGenerativeAIEmbeddings } from &quot;@langchain/google-genai&quot;;<br>import { MemoryVectorStore } from &quot;@langchain/classic/vectorstores/memory&quot;;<br>import { ChatGoogleGenerativeAI } from &quot;@langchain/google-genai&quot;;<br>import { createRetrievalChain } from &quot;@langchain/classic/chains/retrieval&quot;;<br>import { createStuffDocumentsChain } from &quot;@langchain/classic/chains/combine_documents&quot;;<br>import { ChatPromptTemplate } from &quot;@langchain/core/prompts&quot;;<br><br>async function main() {<br>  const loader = new CheerioWebBaseLoader(&quot;https://news.ycombinator.com/&quot;, {<br>    selector: &quot;.titleline&quot;,<br>  });<br><br>  const docs = await loader.load();<br><br>  const splitter = new RecursiveCharacterTextSplitter({<br>    chunkSize: 150,<br>    chunkOverlap: 15,<br>  });<br><br>  const chunks = await splitter.splitDocuments(docs);<br><br>  const embeddings = new GoogleGenerativeAIEmbeddings({<br>    modelName: &quot;gemini-embedding-001&quot;,<br>  });<br><br>  const vectorStore = await MemoryVectorStore.fromDocuments(chunks, embeddings);<br><br>  const model = new ChatGoogleGenerativeAI({<br>    model: &quot;gemini-2.5-flash&quot;,<br>    temperature: 0.3,<br>  });<br><br>  const prompt = ChatPromptTemplate.fromTemplate(`<br> You are a news summarizer. Based ONLY on the context provided below,<br> write a single concise paragraph summarizing the main news topics and trends.<br>Context: {context}<br> Question: {input}<br> `);<br><br>  const combineDocsChain = await createStuffDocumentsChain({<br>    llm: model,<br>    prompt,<br>  });<br><br>  const ragChain = await createRetrievalChain({<br>    retriever: vectorStore.asRetriever({ k: 3 }),<br>    combineDocsChain,<br>  });<br><br>  const result = await ragChain.invoke({<br>    input: &quot;What are the main news stories related to Artificial Intelligence?&quot;,<br>  });<br>  console.log(&quot;\n - - SUMMARY - -\n&quot;);<br>  console.log(result.answer);<br>}<br><br>main();</pre><h4>Conclusion</h4><p>That is a working RAG system in under 100 lines of TypeScript. Five steps, one file. What started as a problem, a language model that cannot see today’s news, became a simple pipeline that loads content, breaks it into pieces, stores those pieces as vectors, retrieves the relevant ones, and hands them to the model with the question.</p><p>This is not production code. It uses an in-memory store, it loads one page, and it runs from a terminal. But the structure is the same as RAG systems used at scale. If you understand these five steps, you understand the foundation.</p><p>From here, you can point the loader at a different URL, swap the in-memory store for Pinecone, or change the question to anything you want. The pipeline stays the same.</p><p>Thanks for reading! Feel free to share your thoughts in the comments, and see you in the next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d0a4fc05c9a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing Maintainable Code: An Introduction to SOLID Principles]]></title>
            <link>https://theek.medium.com/writing-maintainable-code-an-introduction-to-solid-principles-38309c0bd88b?source=rss-dbb05b840f5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/38309c0bd88b</guid>
            <category><![CDATA[object-oriented]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-design]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[solid-principles]]></category>
            <dc:creator><![CDATA[Theekshana Nirmal]]></dc:creator>
            <pubDate>Wed, 26 Nov 2025 15:59:40 GMT</pubDate>
            <atom:updated>2025-11-29T06:42:47.843Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Hello readers!</p><p>When I was working on projects during my 1st year of undergraduate studies, I regularly faced a challenge: whenever I fixed a bug, I created new ones 🥲 Then I realized that the problem was not in the logic, but in the structure and the design of the code.</p><figure><img alt="Image of Spaghetti Code" src="https://cdn-images-1.medium.com/max/1024/1*enAM7CIkeE09OgqpzdzZPQ.jpeg" /><figcaption>Spaghetti Code</figcaption></figure><p>If your code is difficult to read, understand, or modify due to a lack of structure or design, it is commonly referred to as <a href="https://en.wikipedia.org/wiki/Spaghetti_code">Spaghetti Code</a>.</p><p>To avoid Spaghetti Code, I started to explore ways to write better code. This is where the term “SOLID” caught my eye.</p><h3>What is SOLID</h3><p>SOLID is a set of five design principles that help developers write clean, maintainable, and scalable code.</p><p>By following these principles, we can make our code easier to read, test, and modify.</p><p>Here’s what SOLID stands for:</p><p><strong>S </strong>= Single Responsibility Principle (SRP)<br><strong>O </strong>= Open-Closed Principle (OCP)<br><strong>L </strong>= Liskov Substitution Principle (LSP)<br><strong>I </strong>= Interface Segregation Principle (ISP)<br><strong>D </strong>= Dependency Inversion Principle (DIP)</p><p>So, now let’s understand each of these principles one by one.</p><h4>The Single Responsibility Principle (SRP)</h4><figure><img alt="The Single Responsibility Principle (SRP)" src="https://cdn-images-1.medium.com/max/1024/1*aZqwrWbs_kMulHQz6hkkPw.jpeg" /><figcaption>Doing one thing well is better than doing everything poorly.</figcaption></figure><p>The Single Responsibility Principle says that a <a href="https://en.wikipedia.org/wiki/Class_(programming)">Class</a> or module should be responsible for only one thing. If a class tries to do many different things, that class becomes messy and hard to understand or change.</p><p>Let&#39;s look at an example:</p><pre>// Break the Single Responsibility Principle<br>class UserManager {<br>    public void createUser(String name) {<br>        System.out.println(&quot;User created: &quot; + name);<br>    }<br>    <br>    public void sendEmail(String email, String message) {<br>        System.out.println(&quot;Email sent to: &quot; + email);<br>    }<br>}</pre><p>The above code does not follow the Single Responsibility Principle because it does too many things in a single class. Let&#39;s look at a better way to write that code.</p><pre>// Supports the Single Responsibility Principle<br>class UserManager {<br>    public void createUser(String name) {<br>        System.out.println(&quot;User created: &quot; + name);<br>    }<br>}<br><br><br>class EmailService {<br>    public void sendEmail(String email, String message) {<br>        System.out.println(&quot;Email sent to: &quot; + email);<br>    }<br>}</pre><p>As you can see, in the above code, each class has a single responsibility. The UserManager class is only responsible for handling user management, while the EmailService class only handles sending emails, making the code easier to understand and maintain.</p><h4>The Open-Closed Principle (OCP)</h4><figure><img alt="The Open-Closed Principle (OCP)" src="https://cdn-images-1.medium.com/max/1024/1*_3nPo6QtWFXKAWsztCEmUA.jpeg" /><figcaption>The code should be closed for modification, but open for extension</figcaption></figure><p>The Open-Closed Principle means your code should be closed for changes but open for adding new features. Which means, once a class works correctly, it should not be changed to add something new. Instead, extend or implement it. It helps to avoid breaking the existing functionality of the code.</p><p>Let&#39;s look at an example:</p><pre>// Not follows the Open-Closed Principle<br>class Calculator {<br>    public int calculate(int a, int b, String operation) {<br>        // ADD<br>        if (operation.equals(&quot;add&quot;)) {<br>            return a + b;<br>        // Multiply<br>        } else if (operation.equals(&quot;multiply&quot;)) {<br>            return a * b;<br>        } else {<br>            return 0;<br>        }<br>    }<br>}</pre><p>The above code breaks the Open-Closed Principle because whenever you want to add a new feature, such as <em>dividing</em> or <em>subtracting, </em>you are required to change the same class, which can introduce bugs.</p><pre>// Supports the Open-Closed Principle<br>// Interface for operations<br>interface Operation {<br>    int perform(int a, int b);<br>}<br><br>// Existing operation<br>class Add implements Operation {<br>    public int perform(int a, int b) {<br>        return a + b;<br>    }<br>}<br><br>// New operation<br>class Subtract implements Operation {<br>    public int perform(int a, int b) {<br>        return a - b;<br>    }<br>}</pre><p>The above code supports the Open-Closed Principle. It has Operation interface, and this interface can be used to implement new features without changing the old code. New operations are added with new classes only, keeping code safe and maintainable.</p><h4>The Liskov Substitution Principle (LSP)</h4><figure><img alt="The Liskov Substitution Principle (LSP)" src="https://cdn-images-1.medium.com/max/1024/1*ttVm5phj6O5zQ36Vd7abzg.jpeg" /><figcaption>A replacement must not break existing functionality</figcaption></figure><p>The Liskov Substitution Principle means you should be able to replace a base class with its subclasses without breaking the program’s functionality. In other words, a replacement must not break existing functionality.</p><p><strong>FYI:</strong> The Liskov Substitution Principle was initially introduced by Barbara Liskov in a 1987 conference keynote address titled Data Abstraction and Hierarchy. (<em>Source: </em><a href="https://en.wikipedia.org/wiki/Liskov_substitution_principle"><em>Wikipedia</em></a>)</p><p>Let’s look at a code example that <strong>violates</strong> the Liskov Substitution Principle:</p><pre>// Parent class<br>class Bird {<br>    public void fly() {<br>        System.out.println(&quot;Flying&quot;);<br>    }<br>}<br><br>// Subclass that breaks LSP<br>class Ostrich extends Bird {<br>    // Actually Ostrich can&#39;t fly!<br>}<br><br>Bird bird = new Ostrich();<br>bird.fly(); // breaks the program</pre><p>The above code violates the Liskov Substitution Principle. The code assumes that all birds can fly, but we know that the <em>Ostrich</em> can’t fly. So when we replacing Bird with Ostrich breaks the code (Violates LSP).</p><p>Now let’s look at a code example which not violate the Liskov Substitution Principle:</p><pre>// Base interface<br>interface Bird {<br>    void move();<br>}<br><br>// Flying bird<br>class Sparrow implements Bird {<br>    public void move() {<br>        System.out.println(&quot;Flying&quot;);<br>    }<br>}<br><br>// Non-flying bird<br>class Ostrich implements Bird {<br>    public void move() {<br>        System.out.println(&quot;Running&quot;);<br>    }<br>}<br><br>Bird bird1 = new Sparrow();<br>bird1.move(); // Flying<br><br>Bird bird2 = new Ostrich();<br>bird2.move(); // Running</pre><p>Now the above code works for any bird, both Sparrow and Ostrich can be used as a Bird without breaking the code. So the replacement does not break functionalities.</p><h4>The Interface Segregation Principle (ISP)</h4><figure><img alt="The Interface Segregation Principle (ISP)" src="https://cdn-images-1.medium.com/max/1024/1*KlHF21iTJz0GmhAWjl2KbA.jpeg" /><figcaption>Avoid giving extra features that aren’t required</figcaption></figure><p>The Interface Segregation Principle is all about not forcing a class to use methods it doesn&#39;t need. In other words, avoid giving extra features that aren&#39;t required.</p><p>Let’s go through this using an example code that violates ISP:</p><pre>// An interface with too many methods<br>interface Worker {<br>    void work();<br>    void eat();<br>    void sleep();<br>}<br><br>// Class that doesn&#39;t need some methods<br>class Robot implements Worker {<br>    public void work() {<br>        System.out.println(&quot;Robot is working&quot;);<br>    }<br><br>    public void eat() {<br>        // Robots don&#39;t eat<br>    }<br><br>    public void sleep() {<br>        // Robots don&#39;t sleep<br>    }<br>}</pre><p>The above code is breaking the Interface Segregation Principle (ISP). It added unnecessary complexity to the code by implementing methods that are not required for that specific class. The Robot class forced to implement eat() and sleep() methods, even though it doesn&#39;t need.</p><pre>// Separate interfaces<br>interface Workable {<br>    void work();<br>}<br><br>interface Eatable {<br>    void eat();<br>}<br><br>interface Sleepable {<br>    void sleep();<br>}<br><br>// Only implement what is needed<br>// For Robot<br>class Robot implements Workable {<br>    public void work() {<br>        System.out.println(&quot;Robot is working&quot;);<br>    }<br>}<br><br>// For Human<br>class Human implements Workable, Eatable, Sleepable {<br>    public void work() {<br>        System.out.println(&quot;Human is working&quot;);<br>    }<br>    public void eat() {<br>        System.out.println(&quot;Human is eating&quot;);<br>    }<br>    public void sleep() {<br>        System.out.println(&quot;Human is sleeping&quot;);<br>    }<br>}</pre><p>As you can see, the above code uses separate interfaces for each method. This keeps the code clean and simple, avoiding extra features. The Robot only has work() method, no extra unnecessary features, while the Human able to implement all needed methods.</p><h4>The Dependency Inversion Principle (DIP)</h4><figure><img alt="The Dependency Inversion Principle (DIP)" src="https://cdn-images-1.medium.com/max/1024/1*iJ-aXKbAU0kiPQ0yUMpHEA.jpeg" /><figcaption>Depend on abstractions, not concretions. Would you hardwired your lamp to the wall?</figcaption></figure><p>Would you hardwire your lamp to the wall? No right? Instead, you use a plug. The lamp works with any socket that matches the plug. This is flexible!</p><p>Last principle, the Dependency Inversion Principle says the same thing: Your code should work with any class that follows the interface, without changing the high-level logic.</p><p>In other words, depend on abstractions (like interfaces), not on concrete classes. This makes your code flexible and easy to change.</p><p>Now, let’s look at an example code that violates the Dependency Inversion Principle:</p><pre>// High-level class depends on a specific low level class<br>// Low-level class<br>class Lamp {<br>    public void turnOn() {<br>        System.out.println(&quot;Lamp is ON&quot;);<br>    }<br>}<br><br>// High level class<br>class Switch {<br>    private Lamp lamp = new Lamp(); // directly depends on Lamp<br><br>    public void operate() {<br>        lamp.turnOn();<br>    }<br>}</pre><p>The main problem in the above code is that the high-level class (Switch ) directly depending on Lamp the class (The Low-level class). Imagine if you want to turn on the Fan , you can’t because the Switch tightly connected to the Lamp only.</p><p>Every time you add a new device, you have to change the Switch code, which makes the system hard to maintain and not flexible.</p><p>Let’s look at an example code that follows the Dependency Inversion Principle:</p><pre>interface Device {<br>    void turnOn();<br>}<br><br>// Low-level class<br>class Lamp implements Device {<br>    public void turnOn() {<br>        System.out.println(&quot;Lamp ON&quot;);<br>    }<br>}<br><br>// Low-level class<br>class Fan implements Device {<br>    public void turnOn() {<br>        System.out.println(&quot;Fan ON&quot;);<br>    }<br>}<br><br>// High-level class<br>class Switch {<br>    Device device;<br>    Switch(Device device) {<br>        this.device = device;<br>    }<br>    void press() {<br>        device.turnOn();<br>    }<br>}<br><br>// Usage<br>Switch lampSwitch = new Switch(new Lamp());<br>lampSwitch.press(); // Lamp ON<br><br>Switch fanSwitch = new Switch(new Fan());<br>fanSwitch.press(); // Fan ON</pre><p>In the above code, Switch does not care what device it controls. You can plug in a Lamp, a Fan, or anything that follows the Device interface. No need to change Switch for new devices. So this is flexible.</p><h3>Conclusion</h3><p>A good code is not just about making it work; it&#39;s about making a code that is easy to read, maintain, and add new features. So that is exactly what the SOLID principles help us to achieve. By following these five principles, we can avoid messy Spaghetti Code and build software that is clean, stable, scalable, and easy to maintain.</p><p>After learning SOLID, I was able to improve my code quality a lot. I fixed bugs faster, added new features safely, and understood my code more clearly. I hope this guide and these examples help you, too. Start small, apply one principle first, and slowly move to the others. With time, your code will become clean, stable, and easy to maintain.</p><p>So that’s all about SOLID principles.</p><p>Thanks for reading! Feel free to share your thoughts in the comments, and see you in the next post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38309c0bd88b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Your First Azure Virtual Machine: A Beginner’s Guide]]></title>
            <link>https://theek.medium.com/creating-your-first-azure-virtual-machine-a-beginners-guide-3777540baeaa?source=rss-dbb05b840f5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/3777540baeaa</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[virtual-machine]]></category>
            <dc:creator><![CDATA[Theekshana Nirmal]]></dc:creator>
            <pubDate>Wed, 26 Mar 2025 13:14:04 GMT</pubDate>
            <atom:updated>2025-03-28T02:54:34.317Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Creating Your First Azure Virtual Machine: A Beginner’s Guide" src="https://cdn-images-1.medium.com/max/1024/1*77v1TJ5RFdXoCguHkgLmyw.jpeg" /><figcaption>Creating Your First Azure Virtual Machine: A Beginner’s Guide</figcaption></figure><p>In this article, I’ll walk you through creating an <strong>Azure Virtual Machine (VM) </strong>from scratch. Not only will you learn how to set up your VM, also, you’ll discover how to host a simple static web frontend such as a React web app from your GitHub repository on your newly created cloud virtual machine.</p><p>Remember, you’ll need an <a href="https://azure.microsoft.com/en-us/Free"><strong>Azure account</strong></a> and a <a href="https://github.com/"><strong>GitHub account</strong></a> to follow along. If you don’t have one yet, you can usually sign up for a free trial or, if you’re a student, explore the Azure for Students offer.</p><h3>Step 1: Log In to the Azure Portal</h3><p>Begin by visiting the <a href="https://portal.azure.com/">Azure Portal</a> and signing in with your credentials.</p><figure><img alt="Azure Portal" src="https://cdn-images-1.medium.com/max/1024/1*OQQsfxLgjwP1EJcOEO6yMA.png" /><figcaption>Azure dashboard</figcaption></figure><h3>Step 2: Navigate to Virtual Machines</h3><p>Once you’re in the portal, locate the <strong>Virtual Machines</strong> option from the main menu or the search bar.</p><figure><img alt="Azure Portal search bar with Virtual Machines result highlighted" src="https://cdn-images-1.medium.com/max/1024/1*YtkJ3DLhPr06iYFH9u-J1w.png" /><figcaption>In the search bar at the top, type <strong>Virtual machines</strong> and select it from the results.</figcaption></figure><h3>Step 3: Start Creating a New Virtual Machine</h3><figure><img alt="Creating a New Virtual Machine" src="https://cdn-images-1.medium.com/max/1024/1*f0fRJJPb_IogelsPryfpjw.png" /><figcaption>Creating a New Virtual Machine</figcaption></figure><p>Click the <strong>“+ Create”</strong> button and then choose <strong>“Azure virtual machine”</strong> from the options. When you click “+ Create,” you’ll see three choices:</p><figure><img alt="Create options displaying three choices: Azure virtual machine, Azure virtual machine with preset configuration, and More VMs and related solutions" src="https://cdn-images-1.medium.com/max/982/1*XREy74amEQhs4AyNjRucgQ.png" /><figcaption>Choosing Azure Virtual Machine creation option</figcaption></figure><ol><li><strong>Azure virtual machine: </strong>Create a virtual machine hosted by Azure.</li><li><strong>Azure virtual machine with preset configuration</strong>: Create a VM with pre-set options based on your workloads.</li><li><strong>More VMs and related solutions:</strong> Discover and deploy full workloads and other Azure products for your business needs.</li></ol><p>For this guide, select <strong>“Azure virtual machine”</strong>.</p><h3>Step 4: Configure the Basics Tab</h3><p>You’ll now be taken to a page where you need to provide details about your new virtual machine. This page is organized into several tabs. We’ll start with the “Basics” tab.</p><figure><img alt="Azure Virtual Machine Basics tab showing project details, instance details, and security settings" src="https://cdn-images-1.medium.com/max/1024/1*WUkCNzSVdQQDbUq2qTJmlg.png" /><figcaption><strong>Basics</strong> Tab configuration for VM creation</figcaption></figure><h4>Project Details</h4><ul><li><strong>Subscription:</strong> For example, choose <strong>Azure for Students</strong> if available.</li><li><strong>Resource Group:</strong> You can select an existing one or create a new resource group.</li></ul><figure><img alt="Project Details" src="https://cdn-images-1.medium.com/max/987/1*9rlRpGIJvsQ7sZHdQoMohA.png" /><figcaption>Project Details</figcaption></figure><h4><strong>Instance Details:</strong></h4><ul><li><strong>Virtual Machine Name:</strong> Pick a simple name like myFirstVM.</li><li><strong>Region:</strong> Select the region closest to you.</li></ul><p><strong>Availability Zone Options:</strong></p><ul><li><strong>Self-selected zone:</strong> Choose up to 3 zones (one VM per zone).</li><li><strong>Azure-selected zone (Preview):</strong> Let Azure decide the best zone for your needs.</li><li><strong>Availability zone:</strong> By default, Zone 1 is selected. You may choose multiple zones to have one VM per zone.</li></ul><figure><img alt="Instance Details" src="https://cdn-images-1.medium.com/max/983/1*n_BDmokln1tdSJXr-lRqdA.png" /><figcaption>Instance Details</figcaption></figure><h4><strong>Security type:</strong></h4><p>This section determines the security features available for your VM. You’ll see a few options:</p><ul><li><strong>Standard:</strong> This provides the basic level of security for your virtual machine.</li><li><strong>Trusted launch virtual machines:</strong> This offers enhanced security against persistent and advanced attacks, especially for newer generation (Gen 2) VMs. It includes features like secure boot and a virtual Trusted Platform Module (vTPM).</li><li><strong>Confidential virtual machines:</strong> Building on Trusted Launch, this option provides the highest level of confidentiality and integrity by using hardware-based trusted execution environments.</li></ul><figure><img alt="Select security type" src="https://cdn-images-1.medium.com/max/976/1*Sr2YYeEbxGi57A3VMFZhYQ.png" /><figcaption>Select security type</figcaption></figure><p>For our simple tutorial, let’s select <strong>Standard</strong>.</p><h4>Image &amp; VM Architecture</h4><p>This is where you choose the operating system you want to run on your virtual machine. Click on the dropdown, and you’ll see a list of popular operating systems. We want to host a simple web app, and Ubuntu Server is a common and beginner-friendly choice. Let’s select <strong>Ubuntu Server 22.04 LTS — x64 Gen2</strong>.</p><p>Below the dropdown, you’ll see two links:</p><ul><li><strong>See all images:</strong> This will open a new page where you can browse a vast library of operating system images and even pre-configured images with specific software.</li><li><strong>Configure VM generation:</strong> This allows you to choose between Generation 1 and Generation 2 virtual machines. Gen 2 VMs generally support newer features and are recommended for most workloads, which is why our selected image is “Gen2.”</li></ul><p><strong>VM Architecture:</strong> This allows you to choose the processor architecture for your VM. The default is usually <strong>x64</strong>, which is compatible with most software. <strong>Arm64</strong> is a newer architecture that can offer cost and performance benefits for certain workloads, but for our beginner guide, let’s stick with <strong>x64</strong>.</p><p><strong>Run with Azure Spot discount: </strong>This is an interesting option that can significantly reduce the cost of your VM.</p><p><strong>Size: </strong>This determines the hardware configuration of your VM, including the number of virtual CPUs (vCPUs), the amount of memory (RAM), and other resources. You’ll see a default size selected. For our simple web app, the suggested <strong>Standard_D2s_v3–2 vcpus, 8 GiB memory ($80.30/month)</strong> is a good starting point. The monthly cost is an estimate and can vary based on usage.</p><p>Click on the <strong>“See all sizes”</strong> link to explore other options. You’ll find VMs with different combinations of resources and costs. For this beginner guide, we’ll stick with the default <strong>Standard_D2s_v3</strong>.</p><figure><img alt="Image &amp; VM Architecture" src="https://cdn-images-1.medium.com/max/976/1*b8q1w3VJIYURUUw8_bW0ow.png" /><figcaption>Image &amp; VM Architecture</figcaption></figure><h4><strong>Additional Settings</strong></h4><p><strong>Enable Hibernation:</strong></p><ul><li>Hibernation allows you to stop your VM and save its current state to disk, so when you start it again, it resumes from where it left off. This can be useful for saving costs when you’re not actively using the VM. For our beginner guide, we can leave this <strong>unchecked</strong>.</li></ul><p><strong>Administrator account:</strong></p><p>This section is crucial for how you’ll access your virtual machine.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/999/1*eqbGfw3C5Wn3afJmX_lQxA.png" /><figcaption>Administrator account section</figcaption></figure><p><strong>Authentication type:</strong> You have two options:</p><ul><li><strong>SSH public key:</strong> This is a more secure way to connect to Linux VMs. It uses a pair of keys — a public key that you store on the VM and a private key that you keep secret on your local computer. When you connect, your computer proves its identity using the private key. This is generally the recommended method for security.</li><li><strong>Password:</strong> This is the traditional way of logging in using a username and password. While simpler initially, it’s generally less secure than SSH keys.</li></ul><p>For this beginner guide, let’s stick with the default: <strong>SSH public key</strong>.</p><ul><li><strong>Username:</strong> This will be the username for your administrator account on the VM. The default is often “azureuser,” which is fine. You can choose a different username if you prefer, but remember it for later when you connect to the VM. Usernames should typically start with a lowercase letter and can contain letters, numbers, and hyphens.</li></ul><p><strong>SSH public key source:</strong> This determines how you’ll provide the SSH public key to Azure. You have three options:</p><ul><li><strong>Generate new key pair:</strong> Azure will create a new public-private key pair for you. You’ll then need to download the private key file, which you’ll use to connect to the VM. This is the easiest option for beginners.</li><li><strong>Use existing key stored in Azure:</strong> If you’ve previously created SSH keys in Azure, you can select one here.</li><li><strong>Use existing public key:</strong> If you already have an SSH public key, you can paste it into the provided box.</li></ul><p>Let’s choose the default: <strong>Generate new key pair</strong>.</p><ul><li><strong>SSH Key Type:</strong> This specifies the algorithm used to generate the SSH keys. The default is usually <strong>RSA</strong>, which is a widely used and secure algorithm. <strong>Ed25519</strong> is a newer and often more efficient algorithm. For our beginner guide, we can leave it as the default <strong>RSA</strong>.</li><li><strong>Key pair name:</strong> This is the name you’ll give to the SSH key pair that Azure will generate. The default name is usually fine (e.g., a name based on your VM name). Remember this name as you might need to refer to it later.</li></ul><h4>Inbound Port Rules</h4><ul><li><strong>Select inbound ports:</strong> A dropdown will appear with common ports. We definitely want to be able to connect to our VM using SSH, so <strong>SSH (22)</strong> should already be selected by default. Since we plan to host a website, we’ll also need to allow traffic on the standard web ports:</li><li>Check the box for <strong>HTTP (80)</strong>. This is the port used for regular, unencrypted web traffic.</li><li>Check the box for <strong>HTTPS (443)</strong>. This is the port used for secure, encrypted web traffic (which is highly recommended for any public website).</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*P2TjM_gVpR4t0wfpEl-STg.png" /><figcaption>Inbound Port Rules</figcaption></figure><p>Once you’ve filled in all the details on the “Basics” tab, click on the <strong>“Next: Disks &gt;”</strong> button at the bottom.</p><figure><img alt="Click on the Next: Disks &gt; button at the bottom" src="https://cdn-images-1.medium.com/max/998/1*BYERKob_0UH9fjrzq-ZOtw.png" /><figcaption>Click on the <strong>Next: Disks &gt;</strong> button at the bottom</figcaption></figure><h3>Step 5: Configure the Disks</h3><p>On the “Disks” tab, you can configure the storage for your virtual machine. For our beginner guide, we can mostly leave the default settings.</p><figure><img alt="Azure VM Disks tab showing OS disk encryption, disk type selection, and data disk options" src="https://cdn-images-1.medium.com/max/979/1*knHDE7f2X-ZK2YCgK_MmtA.png" /><figcaption>Configure the <strong>Disks</strong></figcaption></figure><p><strong>VM Disk Encryption:</strong> Azure automatically encrypts your data on managed disks.</p><p><strong>OS disk:</strong> This section relates to the disk that will contain your operating system (Ubuntu Server in our case).</p><p><strong>OS disk type:</strong> This determines the performance of your OS disk. The default might be “Premium SSD,” which offers high performance. For our simple tutorial and to potentially save costs, let’s change this to <strong>Standard SSD</strong>. This still provides good performance for most basic workloads.</p><figure><img alt="Change OS disk type to Standard SSD." src="https://cdn-images-1.medium.com/max/1006/1*2VO0qw0qwkue64eXU0wOAQ.png" /><figcaption>Change <strong>OS disk type</strong> to <strong>Standard SSD</strong>.</figcaption></figure><ul><li><strong>Delete with VM:</strong> If you check this box, the OS disk will be deleted when you delete the virtual machine. This is usually what you want.</li><li><strong>Key management:</strong> This relates to encryption keys. We can leave the default “Platform-managed keys.”</li><li><strong>Enable Ultra Disk compatibility:</strong> Ultra Disks are high-performance disks designed for demanding workloads. We don’t need this for our simple setup, so leave it unchecked.</li></ul><p><strong>Data disks:</strong> You can attach additional data disks to your VM for storing more data. Our VM comes with a temporary disk, which is fine for now. We won’t add any additional data disks for this beginner guide.</p><p>Once you’re satisfied with the disk settings (especially changing the <strong>OS disk type</strong> to <strong>Standard SSD</strong>), click on the <strong>“Next: Networking &gt;”</strong> button.</p><h3>Step 6: Configure the Networking Tab</h3><p>The “Networking” tab allows you to configure the network settings for your VM. Again, for our beginner guide, the defaults are generally good.</p><figure><img alt="Azure VM Networking tab showing settings for virtual network, public IP, and inbound ports" src="https://cdn-images-1.medium.com/max/1021/1*784asY0TpibDFFofYz-ISQ.png" /><figcaption><strong>Networking</strong> Tab configuration</figcaption></figure><h3>Step 8: Exploring Other Tabs (Management, Monitoring, Advanced, Tags)</h3><p>For this beginner guide, we won’t make any changes in these tabs. Just click <strong>“Next”</strong> through each of them until you reach the <strong>“Review + create”</strong> tab.</p><p>The following tabs offer more advanced configuration options. For our first VM, we can safely leave most of these with their default settings. Here’s a brief overview of what they are for:</p><ul><li><strong>Management:</strong> This tab allows you to configure options like Microsoft Defender for Cloud integration, enabling system-assigned managed identity, setting up auto-shutdown schedules, configuring backups, and managing guest OS updates.</li></ul><figure><img alt="Azure VM Management tab displaying options like Defender, auto-shutdown, and backups. Then click Next" src="https://cdn-images-1.medium.com/max/957/1*O-qFbtlqavGP0idL2vTg3w.png" /><figcaption>Azure VM Management tab displaying options like Defender, auto-shutdown, and backups. Then click Next</figcaption></figure><ul><li><strong>Monitoring:</strong> Here, you can configure alerts for your VM’s performance and health, enable diagnostics to collect logs and metrics, and set up application health monitoring.</li></ul><figure><img alt="Azure VM Monitoring tab showing alerts and diagnostics options. Click next" src="https://cdn-images-1.medium.com/max/881/1*Zm7nCnjeal-eMVqiyoqQeg.png" /><figcaption>Azure VM Monitoring tab showing alerts and diagnostics options. Click next</figcaption></figure><ul><li><strong>Advanced:</strong> This tab allows you to add extensions to your VM (which are small applications that provide post-deployment configuration and automation tasks) or use cloud-init for custom configurations.</li></ul><figure><img alt="Azure VM Advanced tab with options for additional configuration and extensions. Click next" src="https://cdn-images-1.medium.com/max/992/1*rm0cHw17Webo5H-cj5LWNQ.png" /><figcaption>Azure VM Advanced tab with options for additional configuration and extensions. Click next</figcaption></figure><ul><li><strong>Tags:</strong> Tags are like labels that you can assign to your Azure resources to help you organize them and manage billing.</li></ul><figure><img alt="Azure VM Tags tab showing fields for adding tags to the resource. Click next" src="https://cdn-images-1.medium.com/max/960/1*rcfQBux_SQLjeXtCVKQWwA.png" /><figcaption>Azure VM Tags tab showing fields for adding tags to the resource. Click next</figcaption></figure><p>For this beginner guide, we won’t make any changes in these tabs. Just click <strong>“Next”</strong> through each of them until you reach the <strong>“Review + create”</strong> tab.</p><h3>Step 9: <strong>Review and Create Your Virtual Machine:</strong></h3><p>On the “Review + create” tab, Azure will validate your configuration and show you a summary of all the settings you’ve chosen.</p><p>Take a moment to review everything to make sure it looks correct. If everything seems fine, you’ll see a message saying, “Validation passed.” At the bottom of the page, click the <strong>“Create”</strong> button.</p><figure><img alt="Azure VM Review + Create tab displaying a summary of all settings and a Create button" src="https://cdn-images-1.medium.com/max/1024/1*D-FqGRxIhSrdzacpQ2eE1g.png" /><figcaption>You’ll see a message saying, “Validation passed.” At the bottom of the page, click the <strong>“Create”</strong> button.</figcaption></figure><p>Azure will now start the process of creating your virtual machine. This might take a few minutes. You’ll see a deployment in progress notification.</p><figure><img alt="Azure Portal pop-up window titled ‘Generate new key pair’ with text explaining that Azure doesn’t store the private key and prompting the user to download it by clicking the ‘Download private key and create resource’ button. There is also a ‘Return to create a virtual machine’ button." src="https://cdn-images-1.medium.com/max/1024/1*992E2BrPmn40aAFlA3imKQ.png" /><figcaption>The ‘<strong>Generate new key pair</strong>’ pop-up in the Azure Portal appears after clicking ‘<strong>Create</strong>’ when you’ve chosen to generate a new SSH key. Remember to download and securely store your private key</figcaption></figure><p>This pop-up will inform you that Azure doesn’t store the private key, and you won’t be able to download it again after this step. It’s crucial that you <strong>click the “Download private key and create resource” button</strong> and securely store the downloaded .pem file on your local computer. This file is like the password to your virtual machine, and you&#39;ll need it later to connect.</p><p>Once you’ve downloaded the private key, the virtual machine creation process will continue in the background.</p><h3>Step 10: Locate and Start Your Virtual Machine</h3><p>Once the deployment is complete, you’ll see a notification saying, “Deployment succeeded.”</p><figure><img alt="Azure Portal showing ‘Your deployment is complete’ message for the newly created virtual machine." src="https://cdn-images-1.medium.com/max/1024/1*YRh49MtIzLIDkBvGZ2nE9g.png" /><figcaption>Deployment succeeded! Your Azure Virtual Machine is now created.</figcaption></figure><p>To find your new virtual machine, you can either click the “<strong>Go to resource</strong>” button in the notification or navigate back to the “<strong>Virtual machines</strong>” page in the Azure Portal (using the search bar or the left-hand menu). You should now see your newly created VM listed.</p><h3>Step 11: <strong>Connect to Your VM:</strong></h3><p>Now that your VM is running, you’ll want to connect to it to start configuring it. On the VM’s overview page in the Azure Portal, click the <strong>“Connect”</strong> button.</p><figure><img alt="Azure Portal showing the overview page of a virtual machine named ‘demo-vm’ with the ‘Connect’ button highlighted." src="https://cdn-images-1.medium.com/max/1024/1*w31zdXi8WuSMG-t4Ac30kw.png" /><figcaption>VM Overview: Find your VM details and the ‘Connect’ button here.</figcaption></figure><p>This will open a side panel with options for connecting to your VM. You’ll see information like the public IP address and the default username. Under the <strong>“Most common”</strong> section, you’ll see an option for <strong>“Native SSH”</strong>.</p><figure><img alt="Under the “Most common” section, you’ll see an option for “Native SSH”. Click the “Select” button under “Native SSH”." src="https://cdn-images-1.medium.com/max/1024/1*teHCzmRWBZvHWnW9yqS72g.png" /><figcaption>Click the <strong>“Select”</strong> button under “Native SSH”</figcaption></figure><p>Then a new slide titled <strong>“Native SSH”</strong> will appear, providing detailed instructions on how to connect. (The instructions could be differed from one computer to another based on the operating system of your local computer. in my case, it is a Windows machine)</p><figure><img alt="Then a new slide titled “Native SSH” will appear, providing detailed instructions on how to connect." src="https://cdn-images-1.medium.com/max/1024/1*DijudVTeFTvkYg52tDx2EQ.png" /><figcaption>Then a new slide titled <strong>“Native SSH”</strong> will appear, providing detailed instructions on how to connect.</figcaption></figure><p>The path to your private key file shown in the Azure Portal might be a placeholder like ~/.ssh/id_rsa.pem. <strong>You need to replace this with the actual location where you saved the </strong>.pem<strong> file on your local computer.</strong></p><blockquote>💡<strong> Tip:</strong> If you can’t find your private key, there’s a link to “Reset your SSH private key” in the Azure Portal.</blockquote><figure><img alt="Find the location where you saved the .pem file on your local computer and copy the path." src="https://cdn-images-1.medium.com/max/1024/1*ChzKDlEhWXQFlKU0_UkmGA.png" /><figcaption>Find the location where you saved the .pem file on your local computer and copy the path.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/758/1*_0Mv9DVHNWJ9hNX6FrgPUw.png" /><figcaption>Simply <strong>paste the complete path</strong> where you saved the .pem file on your local computer into this box.</figcaption></figure><p>Once you paste the path, the <strong>“SSH to VM with specified private key”</strong> command displayed below will automatically update to include the correct path to your private key.</p><h3>Step 12: Accessing Your Virtual Machine via your local machine</h3><p>You can then click the copy icon next to the <strong>auto-generated SSH command</strong> to easily copy it to your clipboard. Open your local terminal, paste the command, and press Enter.</p><figure><img alt="SSH to VM with specified private key" src="https://cdn-images-1.medium.com/max/701/1*PM9yWpe5LRW2RTfbMEbZkA.png" /><figcaption>SSH to VM with specified private key</figcaption></figure><p>Once you paste the command into your local machine terminal and press Enter, you might see a message like this (as shown in below screenshot):</p><figure><img alt="Once you paste the command into your terminal and press Enter, you might see a message like this" src="https://cdn-images-1.medium.com/max/1024/1*foIZ06ulG-cakLMkHXy7DQ.png" /><figcaption>Once you paste the command into your terminal and press Enter, you might see a message like this</figcaption></figure><p>This message is a security measure. It means your computer doesn’t recognize the server you’re trying to connect to. This is normal for the first time you connect to a new virtual machine.</p><p>Now type <strong>yes</strong> and press Enter.</p><figure><img alt="Screenshot of a terminal showing the command prompt of an Ubuntu Server virtual machine, with the username ‘azureuser’ and the VM name ‘demo-vm’" src="https://cdn-images-1.medium.com/max/1024/1*4HOdX_X3l47HkrieAi3CBw.png" /><figcaption>Successfully connected! You should now see the command prompt of your Ubuntu Server VM.</figcaption></figure><p>Congratulations! 🎉 You’ve successfully connected to your Azure Virtual Machine. Now, let’s proceed with hosting your simple React frontend on our virtual machine.</p><h3>Step 13: Hosting Your Simple React Web App</h3><p>Now that you have your Ubuntu Server VM running and you’re connected via SSH, let’s host your simple React frontend.</p><p>First, we’ll update the package lists on your Ubuntu system.</p><pre>sudo apt update</pre><p>This command refreshes the package lists from the repositories configured in your system. It’s essential to run this before installing new software to ensure you’re getting the latest versions of packages and their dependencies.</p><p>Next, we’ll install Node.js and npm (Node Package Manager). npm comes bundled with Node.js.</p><pre>sudo apt install nodejs npm</pre><figure><img alt="screenshot of the terminal showing these commands being executed" src="https://cdn-images-1.medium.com/max/1023/1*Q2d4fXh5Fhmc5d2bktvsBw.png" /><figcaption>These commands being executed</figcaption></figure><p>To verify that Node.js is installed correctly, you can check its version:</p><pre>node -v</pre><p>You might find that the version of Node.js installed through apt is not the latest. For React development, it&#39;s often recommended to use a more recent LTS (Long Term Support) version. We can achieve this using Node Version Manager (nvm). Let&#39;s install nvm:</p><pre>sudo apt install curl<br>curl https://raw.githubusercontent.com/creationix/nvm/master/install.sh | bash</pre><p>After running this command, you need to source your bash configuration to make nvm available in your current session:</p><pre>source ~/.bashrc</pre><p>Now you can install the latest LTS version of Node.js using nvm:</p><pre>nvm install --lts</pre><p>Before cloning your React repository, let’s check if Git is already installed on your VM:</p><pre>git --version</pre><p>If Git is not installed, you can install it using the following command:</p><pre>sudo apt install git</pre><p>Now you are ready to clone your React repository from GitHub. Replace &lt;&gt; with the actual URL of your repository:</p><pre>git clone &lt;url-of-your-repository&gt;</pre><figure><img alt="Terminal output showing the successful execution of the git clone command, including prompts for username and password (where a Personal Access Token should be used for the password), and progress updates on receiving and resolving objects from the repository." src="https://cdn-images-1.medium.com/max/1024/1*lk3KAOGGyob7v_zcK5LxBw.png" /><figcaption>Cloning the React app repository from GitHub to the Azure VM.</figcaption></figure><p>Once the cloning is complete, navigate into the project folder using the cd command. You can use the ls command to list the files and folders in your current directory to find the correct folder name.</p><pre>cd &lt;your-project-folder-name&gt;</pre><figure><img alt="Navigate into your project directory" src="https://cdn-images-1.medium.com/max/882/1*FKtQ7rOLlGZ69y_JUXnqbg.png" /><figcaption>Navigate into your project directory</figcaption></figure><p>Finally, install the project dependencies using npm:</p><p>Finally, install the project dependencies using npm:</p><pre>npm install</pre><p>So, it’s a good practice to fix any potential package vulnerabilities:</p><pre>npm audit fix --force</pre><p>After npm install completes, you&#39;ll typically see a message indicating the number of packages installed and potentially some information about vulnerabilities or updates.</p><p>Now, instead of building the production version, let’s start the development server for your React application. Run the following command:</p><pre>npm run dev</pre><figure><img alt="“npm run dev” command will start the development server" src="https://cdn-images-1.medium.com/max/784/1*xttL6G_I8jX-OUQVWC1T_w.png" /><figcaption>Starting the React development server using <strong>npm run dev</strong></figcaption></figure><p>You will likely see output in your terminal indicating that the development server has started and is running on a specific port (usually 5173).</p><figure><img alt="Terminal output showing the execution of the command npm run dev, with messages indicating that the Vite development server has started, including the local and network URLs (e.g., http://localhost:5173/ and http://10.0.0.4:5173/)." src="https://cdn-images-1.medium.com/max/865/1*NJMMXnz4DZqga7HI93E6lA.png" /><figcaption>Vite development server has started, including the local and network URLs</figcaption></figure><p>To access this development server from your local machine using the network URL provided (e.g., http://10.0.0.4:5173/), you will need to ensure that you have configured an inbound port rule in your Azure Virtual Machine&#39;s Network Security Group (NSG) to allow traffic on port 5173.</p><p>Here’s how:</p><p>In the left-hand menu of your VM’s page, under “Settings”, click on <strong>Networking</strong>.</p><figure><img alt="The Azure Portal page for a virtual machine, with the “Networking” option selected in the left-hand sidebar." src="https://cdn-images-1.medium.com/max/1024/1*7g46LJx1A9bk6zNM7kdvBA.png" /><figcaption>Navigating to the Networking settings of your Virtual Machine.</figcaption></figure><p>You will see a button labeled “+ Create port rule”. then click on the button.</p><figure><img alt="Click on the + Create port rule button and select the Inbound port rule" src="https://cdn-images-1.medium.com/max/1024/1*IwwN33zJpAxCqVuR7THGxA.png" /><figcaption>Click on the <strong>+ Create port rule</strong> button and select the<strong> Inbound port rule</strong></figcaption></figure><p>A new panel will appear on the right side of the screen. You need to fill in the following details:</p><ul><li><strong>Source:</strong> Choose <strong>“Any”</strong> to allow connections from any IP address on the internet (for testing). For more security, you could specify your local machine’s public IP address.</li><li><strong>Source port range:</strong> Leave this as * (all ports).</li><li><strong>Destination:</strong> This should be “Any”.</li><li><strong>Destination port range:</strong> Enter <strong>5173</strong>. This is the port your Vite development server is running on.</li><li><strong>Protocol:</strong> Select <strong>“TCP”</strong>.</li><li><strong>Action:</strong> Ensure this is set to <strong>“Allow”</strong>.</li><li><strong>Priority:</strong> Azure will automatically assign a priority. You can usually leave the default.</li><li><strong>Name:</strong> Give your rule a descriptive name, like <strong>“Allow-Vite-5173”</strong>.</li><li><strong>Description (optional):</strong> You can add a description if you want.</li></ul><figure><img alt="Once you have filled in all the details, click the “Add” button to create the inbound rule." src="https://cdn-images-1.medium.com/max/886/1*ctUaL-h4RjpgCdj3WyqVHA.png" /><figcaption>Once you have filled in all the details, click the “Add” button to create the inbound rule.</figcaption></figure><p>Once you have filled in all the details, click the <strong>“Add”</strong> button at the bottom of the side panel.</p><p>It will take a few moments for the rule to be created and applied.</p><p>The network URL http://10.0.0.4:5173/ that Vite provides is an internal IP address within your Azure virtual network. This address is not directly accessible from your local machine over the public internet.</p><p>To access your development server from your local computer, you need to use the <strong>public IP address</strong> of your Azure Virtual Machine followed by the port number.</p><p>You can easily find the public IP address of your VM in the Azure Portal:</p><ol><li>Go to your Virtual Machine’s overview page (you can search for your VM name in the top search bar).</li><li>In the left-hand menu, under “Operations”, click on <strong>“Connect”</strong>.</li><li>Under the “Connect” section, you will see the <strong>“Public IP address”</strong> listed. Use this public IP address in your web browser along with the port number 5173 to access your running development server.</li></ol><figure><img alt="The Azure Portal page for a virtual machine, with the “Connect” option selected in the left-hand sidebar." src="https://cdn-images-1.medium.com/max/1024/1*foAdEreG0kfJ8KTRUrS4Ow.png" /><figcaption>Navigating to the “<strong>Connect</strong>” section to find the public IP address.</figcaption></figure><p>In my case, my public IP address is <strong>20.119.81.56</strong>. Therefore, I open my web browser on my local machine and navigate to:</p><pre>http://20.119.81.56:5173/</pre><p>If everything is set up correctly and your React development server is running, when you navigate to http://&lt;your-public-ip&gt;:5173/ in your web browser, you should see the default welcome page or the main interface of your React application. This will depend on how your React app is structured.</p><figure><img alt="A web browser displaying the default welcome screen of a React application running on a development server, possibly showing the React logo, links to documentation, or the basic layout of the user’s app." src="https://cdn-images-1.medium.com/max/855/1*1EeIT-j67QzDNIjwUbMlzg.png" /><figcaption>The React development server welcome page or your application’s main interface as viewed in a web browser</figcaption></figure><h3><strong>Key Takeaways</strong></h3><ul><li>You now understand the fundamentals of creating your first Azure Virtual Machine using the Azure Portal.</li><li>You’ve learned how to configure basic network settings, including adding inbound port rules to allow access to your VM.</li><li>You’ve gained experience in establishing a secure connection to your cloud server using SSH.</li><li>You’ve seen how to retrieve your web application code by cloning a repository from GitHub onto your VM.</li><li>You’ve learned how to start your React frontend development server on the Azure VM using npm run dev.</li><li>You now know how to access your running web application from your local machine using the VM’s public IP address and the development server’s port.</li></ul><h3><strong>Conclusion</strong></h3><p>In this beginner’s guide, you’ve successfully taken your first steps into the world of cloud computing with Azure. You’ve not only learned how to create an Azure Virtual Machine from scratch but also gained hands-on experience in hosting a simple static web frontend, a React application from your GitHub repository on this newly created cloud server.</p><p>From setting up your virtual machine and configuring essential network rules to securely connecting via SSH and cloning your project, you’ve navigated the fundamental processes of deploying an application to the cloud. You’ve even spun up your React development server, allowing you to see your frontend in action.</p><p>This journey provides a solid foundation for further exploration and more complex deployments on Azure. Keep building, keep learning, and you’ll unlock the vast potential of cloud computing for your projects!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3777540baeaa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide: Deploying Your First Static Web Site using Azure App Services]]></title>
            <link>https://theek.medium.com/a-beginners-guide-deploying-your-first-static-web-site-using-azure-app-services-400b303fd511?source=rss-dbb05b840f5a------2</link>
            <guid isPermaLink="false">https://medium.com/p/400b303fd511</guid>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[cloud-services]]></category>
            <category><![CDATA[azure-app-service]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[microsoft-azure]]></category>
            <dc:creator><![CDATA[Theekshana Nirmal]]></dc:creator>
            <pubDate>Tue, 25 Mar 2025 07:58:33 GMT</pubDate>
            <atom:updated>2025-03-25T08:07:06.381Z</atom:updated>
            <content:encoded><![CDATA[<p>Are you want to share your newly built static website (like a simple frontend) with the world? <strong>Azure App Service</strong> simplifies the deployment process, making it accessible even for those new to cloud platforms. In this article, I’ll guide you through the step-by-step process of deploying your site from a GitHub repository to Azure Static Web Apps. Let’s get started!</p><figure><img alt="Image of Azure App Service" src="https://cdn-images-1.medium.com/max/828/0*qFNQWOMjR_VZGlA4.png" /><figcaption><strong>Azure App Service</strong> simplifies the deployment process.</figcaption></figure><h3>Step 1: Prepare Your Accounts</h3><p>Before you start, ensure you have:</p><ul><li><strong>An Azure Account:</strong> This gives you access to the Azure portal to manage your cloud resources. <a href="https://azure.microsoft.com/en-us/pricing/purchase-options/azure-account">Create Your Azure Free Account</a></li><li><strong>A GitHub Account:</strong> Your website’s code will be hosted in a GitHub repository. Make sure you have pushed your site’s code there. <a href="https://github.com/">Create a GitHub Account</a></li></ul><blockquote><strong>💡 Tip:</strong> If your repository isn’t set up yet, create one and push your code. This repository is the starting point for deployment.</blockquote><h3>Step 2: Push Your Code to GitHub</h3><p>Push your website’s code to your GitHub repository. Azure will use this repository to fetch your code during deployment.</p><figure><img alt="Github repository" src="https://cdn-images-1.medium.com/max/1024/1*li_-V0i2RbPwDRz_ojhxuw.png" /><figcaption>Screenshot: GitHub repository</figcaption></figure><h3>Step 3: Access the Azure Portal and Start Deployment</h3><ol><li><strong>Log in to the Azure Portal:</strong> Open <a href="https://portal.azure.com/">portal.azure.com</a> and sign in.</li></ol><figure><img alt="Screenshot of the Azure portal homepage" src="https://cdn-images-1.medium.com/max/1024/1*7LNUFa6_OsAPrwp_1mQqPg.png" /><figcaption>Azure portal homepage</figcaption></figure><ol><li><strong>Search for “App Services”: </strong>Once you’re logged in, you’ll see the Azure dashboard. In the search bar at the top, type “App Services” and press Enter.</li></ol><figure><img alt="Screenshot of the Azure portal with “Apps services” typed in the search bar and the search results showing the Apps service." src="https://cdn-images-1.medium.com/max/1024/1*kuWKUHbdTmjM_zJ7-SZM9A.png" /><figcaption>Searching for “Static Web Apps” in Azure</figcaption></figure><ol><li><strong>Create a New App Service: </strong>On the “App Services” page, you’ll see a <strong>Create</strong> button. Click on the small down arrow next to it.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8fsTuYMpxWsuy3FIvhdSHw.png" /><figcaption>You’ll see a <strong>Create</strong> button. Click on the small down arrow next to it</figcaption></figure><p>When you click the small down arrow next to the “Create” button, you might notice a few options. Here’s a simple breakdown of what they mean:</p><ul><li><strong>Web App:</strong> This is the most common option for hosting web applications. It’s designed for dynamic websites that might have a backend server (like those built with Python, Node.js, or .NET).</li><li><strong>Static Web App:</strong> This is the perfect choice for our simple front-end website. It’s optimized for hosting static content (HTML, CSS, JavaScript) and often comes with built-in features for serverless functions.</li><li><strong>Web App + Database:</strong> This option helps you quickly create a web application along with a database (like Azure SQL Database). It’s useful for applications that need to store and retrieve data.</li><li><strong>WordPress on App Service:</strong> This option simplifies the process of setting up and running a WordPress blog or website on Azure.</li></ul><p>Since our website is a simple front-end application, we’re choosing <strong>Static Web App</strong>.</p><figure><img alt="Screenshot of the Azure App service page with the “Create” button highlighted." src="https://cdn-images-1.medium.com/max/1024/1*aRONsvDkx3Am18Ym9bLyLA.png" /><figcaption>Creating a new Static Web App</figcaption></figure><h3>Step 4: Configure Your Static Web App</h3><h4>Section 01: Basics Tab</h4><p>You’ll now be taken to the “Create Static Web App” page. We’ll start with the “Basics” tab.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/991/1*5xwwQPmdSAmjexA3AS-XNw.png" /><figcaption>“Basics” tab</figcaption></figure><p><strong>1) Project Details:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/936/1*NscoizwMRCphbYmbn2j9jA.png" /><figcaption>“Project Details” section</figcaption></figure><ul><li><strong>Subscription:</strong> This is like your billing account in Azure. Choose the Azure subscription you want to use for this project from the dropdown menu. If you’re a student, you might see “Azure for Students” here.</li><li><strong>Resource Group:</strong> Think of a resource group as a folder where you can organize all the resources related to your website. You can either select an existing resource group from the dropdown or click <strong>Create new</strong> to create a new one. Give it a descriptive name, like my-static-website-group.</li></ul><p><strong>2) Static Web App details:</strong></p><ul><li><strong>Name:</strong> This is the unique name for your static web app. This name will also be part of your website’s URL (e.g., your-app-name.azurestaticapps.net).</li></ul><p>Here are a few name ideas and rules:</p><ul><li>Use lowercase letters and numbers.</li><li>You can use hyphens (-) but not at the beginning or end.</li><li>Make it something memorable and relevant to your website.</li><li>Examples: my-portfolio-site, simple-blog-app, company-landing-page.</li></ul><p><strong>3) Hosting plan:</strong></p><p>This determines the resources and features available for your website. Click on the dropdown menu under “Plan type”. You’ll see a few options:</p><figure><img alt="Screenshot showing the three hosting plan options: Free, Standard, and Dedicated, with a brief explanation of each." src="https://cdn-images-1.medium.com/max/851/1*g8rFz1gJP05fLkoCNOYIBQ.png" /><figcaption>Choosing a hosting plan</figcaption></figure><ul><li><strong>Free:</strong> This is a great option for personal projects or hobby sites. It offers limited features but is completely free!</li><li><strong>Standard:</strong> Suitable for general-purpose production applications. It offers more resources and features than the Free plan.</li><li><strong>Dedicated (preview):</strong> Another option for production apps, offering even more dedicated resources.</li></ul><p>For this beginner’s guide, the <strong>Free</strong> plan is usually sufficient.</p><ul><li><strong>Regions:</strong> This refers to the geographical location where your app will be hosted. For a static website, you can generally leave this as <strong>Global</strong>, as Azure Static Web Apps uses a global content delivery network (CDN) to serve your website quickly to users around the world.</li></ul><p><strong>4) Deployment details:</strong></p><figure><img alt="Screenshot of the “Deployment details” section, showing GitHub as the selected source for deployment, along with the options to choose an organization, repository, and branch." src="https://cdn-images-1.medium.com/max/879/1*VZvLLXB4-GB9q6-_kUJ1Mg.png" /><figcaption>Screenshot of the “Deployment details” section, showing GitHub as the selected source for deployment, along with the options to choose an organization, repository, and branch.</figcaption></figure><ul><li><strong>Source:</strong> Since your code is on GitHub, select <strong>GitHub</strong> from the dropdown menu.</li><li><strong>GitHub account:</strong> If you haven’t connected your Azure account to your GitHub account before, you might be prompted to authorize Azure to access your GitHub repositories. Click on <strong>Select account</strong> or <strong>Change account</strong> and follow the on-screen instructions to link your accounts.</li><li><strong>Select organization:</strong> Choose the GitHub organization (or your personal account) where your repository is located.</li><li><strong>Select repository:</strong> From the dropdown menu, find and select the repository containing your website’s code.</li><li><strong>Select branch:</strong> Choose the branch of your repository that you want to deploy (usually the main or master branch).</li></ul><p><strong>5) Build Details:</strong></p><p>After you’ve selected your GitHub repository and branch, you’ll see a section called <strong>Build Details</strong>. This is where you tell Azure how to build your website (if it needs a build step, like for React applications).</p><figure><img alt="Build Details" src="https://cdn-images-1.medium.com/max/908/1*TTC1xwO-L1EVLEBU4aPYlA.png" /><figcaption>Build Details</figcaption></figure><ul><li><strong>Build Presets:</strong> Azure might automatically detect the type of application in your repository (like “React” in the screenshot). These presets suggest default values for your project structure.</li><li><strong>App location:</strong> This field specifies the location of your application code within your repository. If your main website files (like your index.html file or the entry point of your React app) are in the root of your repository, you&#39;ll typically see ./ here. If they are in a subfolder (like /frontend as shown in the example), you&#39;ll need to enter that path.</li><li><strong>Api location:</strong> If your website has any serverless functions (which is an advanced topic), you would specify the location of those functions here (e.g., api or functions). For a simple static website without any backend functions, you can leave this blank.</li><li><strong>Output location:</strong> This is a very important setting! It tells Azure where to find the final, built version of your website after any necessary build process. For example, if you’re using React, after you run the npm run build command, your website files are usually placed in a build folder. You would then enter build in this field. Similarly, for other frameworks like Vue.js, it might be dist. If your website consists of just plain HTML, CSS, and JavaScript files at the root, you might be able to leave this blank.</li><li><strong>Workflow configuration:</strong> You’ll also see a button to <strong>Preview workflow file</strong>. This allows you to see the GitHub Actions workflow file that Azure will automatically create in your repository. This file defines the steps for building and deploying your website whenever you push changes to your chosen branch.</li></ul><h4>Section 02: Deployment Configuration Tab</h4><figure><img alt="Deployment Configuration button" src="https://cdn-images-1.medium.com/max/923/1*wCFHi8rsvOLMtk3sHSjSdg.png" /><figcaption>Deployment Configuration button</figcaption></figure><p>Click on the <strong>Deployment configuration</strong> button at the bottom. This section essentially tells Azure how it’s allowed to automatically update your website when you make changes to your code on GitHub.</p><figure><img alt="Screenshot of the “Deployment Configuration” section, where the deployment authorization policy “Deployment Token” is selected." src="https://cdn-images-1.medium.com/max/905/1*QYeDJ-701Wkh_mVBAetH2Q.png" /><figcaption>Choosing the deployment authorization policy</figcaption></figure><p>Here, you’ll see options for “Deployment authorization policy”.</p><ul><li><strong>Deployment token:</strong> Azure Static Web Apps can use a unique token to authorize deployments. This is a secure way to manage deployments.</li><li><strong>GitHub:</strong> Since we connected our GitHub account, we can also use GitHub Identity for deployment authorization.</li></ul><p>For this beginner’s guide, you can leave the default selection. Azure Static Web Apps will automatically set up a GitHub Actions workflow in your repository to handle the deployment process whenever you push changes to the selected branch.</p><figure><img alt="Click the “Next: Advanced” button at the bottom" src="https://cdn-images-1.medium.com/max/897/1*HkGe2IowuMsQ_0haTsL-GQ.png" /><figcaption>Click the “Next: Advanced” button at the bottom</figcaption></figure><h4>Section 03: Advanced Settings</h4><p>For this deployment, I didn’t adjust the advanced settings. Here’s a brief overview:</p><ul><li><strong>Azure Functions API and Staging:</strong> Options are available to integrate serverless functions and manage staging environments. If needed, I could choose a region (e.g., West US 2, Central US).</li><li><strong>Enterprise-grade Edge:</strong> There’s an option to integrate with Azure Front Door for enhanced global performance.</li></ul><figure><img alt="Screenshot of the Advanced Settings tab" src="https://cdn-images-1.medium.com/max/936/1*Gh5U-7z9EV5fowDrRllPfQ.png" /><figcaption><strong>Advanced Settings</strong> tab. Left them as default and click the <strong>Next: Tags</strong> button at the bottom</figcaption></figure><p>These settings are pre-configured for most simple deployments, so I left them as default.</p><h4>Section 04: Tags</h4><p>Tags are name/value pairs that help categorize resources for management and billing.</p><ul><li><strong>Name &amp; Value:</strong> I can assign tags to organize my resources, but for this basic deployment, I left them as default.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*Gy44jbXtFfnQfycZLH3NYQ.png" /><figcaption>Screenshot of the <strong>Tags</strong> tab. Left them as default and click the <strong>Next: Review + create</strong> button</figcaption></figure><h4>Section 05: Review + Create</h4><p>You can now review the summary of the configuration that we made before finalizing:</p><figure><img alt="Screenshot of the “Review + Create” page displaying a summary of the Static Web App details, including name, region, SKU, repository, and branch." src="https://cdn-images-1.medium.com/max/734/1*zq_hAuOJZS7AZr1L4D1FYg.png" /><figcaption>Reviewing the configuration before deployment</figcaption></figure><p><strong>Summary Details:</strong> This includes my Static Web App details, subscription, resource group, name, region, plan (SKU), repository, branch, and deployment policy.</p><ul><li><strong>Subscription:</strong> Your chosen Azure subscription.</li><li><strong>Resource Group:</strong> The resource group you selected or created.</li><li><strong>Name:</strong> The unique name you gave to your Static Web App.</li><li><strong>Region:</strong> Usually westus2 or a similar global region for the Static Web App itself (the actual content is served globally).</li><li><strong>SKU:</strong> The hosting plan you selected (e.g., Standard).</li><li><strong>Repository:</strong> The GitHub repository you linked.</li><li><strong>Branch:</strong> The branch you selected for deployment.</li><li><strong>App location:</strong> This is usually / indicating the root of your repository.</li><li><strong>API location:</strong> If you had any serverless functions in your repository, you would specify their location here. For a basic static website, you can leave this blank.</li><li><strong>Output location:</strong> This specifies the folder in your repository that contains the built website files (e.g., build for React apps, dist for Vue.js apps, or just leave it blank if your HTML file is at the root). <strong>Make sure to configure this correctly based on your project structure!</strong></li><li><strong>Deployment authorization policy:</strong> Indicates how deployments are authorized (e.g., GitHub).</li></ul><p>Below the summary, you might see an option to <strong>Download a template for automation</strong>. This allows you to download a JSON file that describes your configuration, which can be useful if you want to automate the creation of similar resources in the future. For now, this is optional.</p><h3><strong>Step 5: Click “Create”</strong></h3><p>Once you’ve reviewed the summary and everything looks correct, click the <strong>Create</strong> button at the bottom.</p><figure><img alt="A screenshot of click the “Create” button at the bottom." src="https://cdn-images-1.medium.com/max/745/1*980qYqmX354C--Q31gxcfA.png" /><figcaption>Click the <strong>Create</strong> button at the bottom.</figcaption></figure><h3><strong>Step 6: Wait for Deployment</strong></h3><p>Azure will now start the deployment process. This is handled automatically by GitHub Actions. You can monitor the progress in the Azure portal notifications or by going to your GitHub repository and checking the “Actions” tab.</p><figure><img alt="Screenshot of the Azure portal showing the deployment process of the Static Web App" src="https://cdn-images-1.medium.com/max/680/1*oELLU7Vv66vsBZ0jslCOAw.png" /><figcaption>Deployment in progress</figcaption></figure><h3><strong>Step 7: Access Your Deployed Website</strong></h3><p>Once the deployment is complete (it might take a few minutes), you’ll receive a notification in the Azure portal. You can also find the production URL of your website in the overview section of your Static Web App resource in the Azure portal. It will look something like app-name.azurestaticapps.net.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kpWX-z5d68dTLG0jnJw1AA.png" /><figcaption>To access the production URL, Click the <strong>Go to resource</strong> button</figcaption></figure><figure><img alt="Click View your site button" src="https://cdn-images-1.medium.com/max/1024/1*uqwJ5LaDowtH90KyiEvi0w.png" /><figcaption>Click <strong>View your site</strong> button</figcaption></figure><p>Click on this URL, and congratulations! 🎉 Your static website should now be live on the internet.</p><figure><img alt="Screenshot showing the production URL of the deployed Static Web App in the Azure portal, ready to be accessed in a browser." src="https://cdn-images-1.medium.com/max/914/1*0vSHE2dRMpbnuP9uCYElGA.png" /><figcaption>Viewing the deployed web app by using the URL</figcaption></figure><h4><strong>Key Takeaways</strong></h4><p>Let’s quickly recap what you’ve learned:</p><ul><li>Azure App Services (specifically Static Web Apps) is a simple way to host front-end websites.</li><li>You can easily connect your GitHub repository to automatically deploy your website.</li><li>The Azure portal provides a user-friendly interface for configuration.</li><li>GitHub Actions handles the deployment process whenever you update your code.</li><li>Your website gets a free subdomain under azurestaticapps.net.</li></ul><h3><strong>Conclusion</strong></h3><p>Deploying your first website might seem scary at first, but with Azure App Services, it becomes a simple process. By following these simple steps, you’ve successfully launched your static website from a GitHub repository and made it accessible to the world. This is just the beginning of your web development journey, and Azure offers many more powerful features to explore as your needs grow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=400b303fd511" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>