<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nalin Jayasinghe</title>
    <description>The latest articles on DEV Community by Nalin Jayasinghe (@nalinj).</description>
    <link>https://dev.to/nalinj</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F604782%2Fdc647cf3-d230-4a05-915f-ca441c2ffbd3.png</url>
      <title>DEV Community: Nalin Jayasinghe</title>
      <link>https://dev.to/nalinj</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nalinj"/>
    <language>en</language>
    <item>
      <title>Understanding Programming: From Machine Language to .NET</title>
      <dc:creator>Nalin Jayasinghe</dc:creator>
      <pubDate>Tue, 04 Feb 2025 10:39:56 +0000</pubDate>
      <link>https://dev.to/nalinj/understanding-programming-from-machine-language-to-net-3fao</link>
      <guid>https://dev.to/nalinj/understanding-programming-from-machine-language-to-net-3fao</guid>
      <description>&lt;p&gt;In this post, we will write the same program "Hello, World!" in three different languages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Machine Language (Binary)&lt;/li&gt;
&lt;li&gt;Assembly Language (Human-Readable Machine Code)&lt;/li&gt;
&lt;li&gt;.NET (C# - High-Level Programming)&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  Machine Language – The Pure Binary Code
&lt;/h2&gt;

&lt;p&gt;At the core of every computer is the CPU (Central Processing Unit), which only understands binary instructions &lt;code&gt;1&lt;/code&gt; and &lt;code&gt;0&lt;/code&gt;. This is called Machine Language (or machine code).&lt;/p&gt;

&lt;p&gt;Here’s an x86 Linux machine code program that prints "Hello, World!":&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight scss"&gt;&lt;code&gt;&lt;span class="nt"&gt;10111000&lt;/span&gt; &lt;span class="nt"&gt;00000100&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt;
&lt;span class="nt"&gt;10111011&lt;/span&gt; &lt;span class="nt"&gt;00000001&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt;
&lt;span class="nt"&gt;10111001&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt; &lt;span class="nt"&gt;00010000&lt;/span&gt; &lt;span class="nt"&gt;01100000&lt;/span&gt;
&lt;span class="nt"&gt;10111010&lt;/span&gt; &lt;span class="nt"&gt;00001101&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt;
&lt;span class="nt"&gt;11001101&lt;/span&gt; &lt;span class="nt"&gt;10000000&lt;/span&gt;
&lt;span class="nt"&gt;10111000&lt;/span&gt; &lt;span class="nt"&gt;00000001&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt; &lt;span class="nt"&gt;00000000&lt;/span&gt;
&lt;span class="nt"&gt;11001101&lt;/span&gt; &lt;span class="nt"&gt;10000000&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The binary code directly controls the CPU to make the system perform tasks such as displaying text on the screen.&lt;/li&gt;
&lt;li&gt;It’s extremely difficult to read and write manually, which is why higher-level languages were developed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is why Assembly Language exists to make machine instructions human-readable.&lt;/p&gt;




&lt;h2&gt;
  
  
  Assembly Language – A Step Closer to Humans
&lt;/h2&gt;

&lt;p&gt;Instead of raw binary, Assembly Language allows us to use mnemonics (like &lt;code&gt;MOV&lt;/code&gt;, &lt;code&gt;INT&lt;/code&gt;) to represent machine instructions.&lt;/p&gt;

&lt;p&gt;Here’s the same "Hello, World!" program in x86 Assembly:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;section .data
    message db "Hello, World!", 0xA  ; Define message string

section .text
    global _start  

_start:
    mov eax, 4       ; System call number (sys_write)
    mov ebx, 1       ; File descriptor (stdout)
    mov ecx, message ; Message address
    mov edx, 13      ; Message length
    int 0x80         ; Call kernel (print message)

    mov eax, 1       ; System call number (sys_exit)
    int 0x80         ; Exit program
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Readable mnemonics (&lt;code&gt;MOV&lt;/code&gt;, &lt;code&gt;INT&lt;/code&gt;) replace binary opcodes.&lt;/li&gt;
&lt;li&gt;Still CPU-specific (different CPUs have different assembly syntax).&lt;/li&gt;
&lt;li&gt;Better than raw machine code but still hard to write for complex applications.
This is why we use high-level languages like .NET (C#).&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  .NET and High-Level Programming
&lt;/h2&gt;

&lt;p&gt;Instead of dealing with system calls and registers, we can simply write:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Hello, World!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  How It Works
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;The C# compiler converts this into Intermediate Language (IL).&lt;/li&gt;
&lt;li&gt;The .NET runtime (CLR - Common Language Runtime) translates IL into machine code at runtime.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Console.WriteLine()&lt;/code&gt; abstracts away low-level system calls, making it easier to print text.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Comparison of All Three Approaches
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;strong&gt;Feature&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Machine Code&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;Assembly Language&lt;/strong&gt;&lt;/th&gt;
&lt;th&gt;&lt;strong&gt;.NET (C#)&lt;/strong&gt;&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Readability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Hard (binary)&lt;/td&gt;
&lt;td&gt;Medium (mnemonics)&lt;/td&gt;
&lt;td&gt;Easy (English-like syntax)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Portability&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;CPU-specific&lt;/td&gt;
&lt;td&gt;CPU-specific&lt;/td&gt;
&lt;td&gt;Cross-platform (Windows, Linux, macOS)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Productivity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Very low&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Performance&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Very high&lt;/td&gt;
&lt;td&gt;High&lt;/td&gt;
&lt;td&gt;High (Managed by runtime)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Conclusion: From Machine Code to .NET
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Machine code is the raw language of computers (binary) and is tightly tied to the hardware architecture (CPU-specific).&lt;/li&gt;
&lt;li&gt;Assembly language is a step up but still closely tied to hardware.&lt;/li&gt;
&lt;li&gt;.NET (C#) allows developers to write clean, portable, and powerful applications without worrying about system calls or registers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;By using high-level languages like C# in .NET, we can focus on solving real-world problems without dealing with low-level hardware details.&lt;/p&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>assembly</category>
      <category>programming</category>
    </item>
    <item>
      <title>Handling Missing Configuration with Fallback Values in Azure Functions</title>
      <dc:creator>Nalin Jayasinghe</dc:creator>
      <pubDate>Mon, 26 Aug 2024 12:08:04 +0000</pubDate>
      <link>https://dev.to/nalinj/handling-missing-configuration-with-fallback-values-in-azure-functions-103l</link>
      <guid>https://dev.to/nalinj/handling-missing-configuration-with-fallback-values-in-azure-functions-103l</guid>
      <description>&lt;p&gt;When developing Azure Functions, it’s essential to handle configuration values gracefully, especially if some values might be missing. In this post, we’ll explore how to use fallback values in Azure Functions for a timer trigger to ensure reliable operation even when configuration is incomplete.&lt;/p&gt;

&lt;h2&gt;
  
  
  Function Definition
&lt;/h2&gt;

&lt;p&gt;Let's start with the function definition. Here’s how you can set up a timer-triggered Azure Function that uses an environment variable for its schedule:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;FunctionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DataProcessingFunction"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nf"&gt;TimerTrigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%MyFooSchedule%"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="n"&gt;TimerInfo&lt;/span&gt; &lt;span class="n"&gt;myTimer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ILogger&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"DataProcessingFunction executed at: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="c1"&gt;// Your function logic here&lt;/span&gt;
    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CompletedTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;[FunctionName("DataProcessingFunction")]&lt;/code&gt;: This attribute names the function.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[TimerTrigger("%MyFooSchedule%")]&lt;/code&gt;: The function is triggered based on the schedule defined by the &lt;code&gt;MyFooSchedule&lt;/code&gt; environment variable.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ILogger log&lt;/code&gt;: Used to log execution details.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sample appsettings.json
&lt;/h2&gt;

&lt;p&gt;Here is an example of what your &lt;code&gt;appsettings.json&lt;/code&gt; file might look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"AzureWebJobsStorage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"UseDevelopmentStorage=true"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"MyFooSchedule"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"0 */15 * * * *"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;//&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;This&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;is&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;schedule&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;for&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;the&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;timer&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="err"&gt;trigger&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"FUNCTIONS_WORKER_RUNTIME"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"dotnet"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;AzureWebJobsStorage&lt;/code&gt;: Specifies the storage account used by Azure Functions.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;MyFooSchedule&lt;/code&gt;: Defines the timer schedule for the function. In this example, it triggers every 15 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;FUNCTIONS_WORKER_RUNTIME&lt;/code&gt;: Indicates that the function app uses the .NET runtime.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Use Default Environment Values?
&lt;/h2&gt;

&lt;p&gt;Using default environment values for timer triggers offers several benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Reliability&lt;/strong&gt;: Default values ensure that your function will continue to operate even if the expected configuration is missing. Without a default, a missing schedule might prevent the function from running entirely.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Ease of Development&lt;/strong&gt;: During development and testing, you might not always have all configuration values set up. Default values allow you to test your function without needing to configure every detail in the environment.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistency Across Environments&lt;/strong&gt;: When deploying to different environments (e.g., development, staging, production), having default values helps maintain consistent behavior if environment-specific configurations are not set.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Error Prevention&lt;/strong&gt;: Default values prevent runtime errors and issues related to missing or incorrect configurations. This makes your function more robust and easier to manage.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Static Constructor for Default Values
&lt;/h2&gt;

&lt;p&gt;To handle cases where MyFooSchedule might not be set, use a static constructor to provide a default value:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;DataProcessingFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Default schedule (every 5 minutes)&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;defaultSchedule&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0 */5 * * * *"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;schedule&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MyFooSchedule"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="n"&gt;defaultSchedule&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Set the environment variable&lt;/span&gt;
    &lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MyFooSchedule"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Default Value&lt;/strong&gt;: &lt;code&gt;"0 */5 * * * *"&lt;/code&gt; specifies a default schedule of every 5 minutes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check and Set&lt;/strong&gt;: The constructor checks if &lt;code&gt;MyFooSchedule&lt;/code&gt;is set. If not, it assigns the default value.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Full Code Example
&lt;/h2&gt;

&lt;p&gt;Combining both parts, here’s the complete code for the Azure Function with fallback configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;System.Threading.Tasks&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Azure.WebJobs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.Logging&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;MyFunctionApp&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DataProcessingFunction&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="nf"&gt;DataProcessingFunction&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Default schedule (every 5 minutes)&lt;/span&gt;
            &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;defaultSchedule&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"0 */5 * * * *"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;schedule&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MyFooSchedule"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="n"&gt;defaultSchedule&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

            &lt;span class="c1"&gt;// Ensure the environment variable is set&lt;/span&gt;
            &lt;span class="n"&gt;Environment&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;SetEnvironmentVariable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MyFooSchedule"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;schedule&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;FunctionName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DataProcessingFunction"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nf"&gt;TimerTrigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"%MyFooSchedule%"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="n"&gt;TimerInfo&lt;/span&gt; &lt;span class="n"&gt;myTimer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;ILogger&lt;/span&gt; &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;log&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"DataProcessingFunction executed at: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Now&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="c1"&gt;// Your function logic here&lt;/span&gt;
            &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;CompletedTask&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;By using a static constructor to provide fallback values, you ensure that your Azure Function can handle missing configuration gracefully. This approach enhances the reliability of your function and simplifies the process of maintaining and debugging configuration issues. Default environment values not only prevent runtime errors but also improve the consistency and robustness of your functions across different environments.&lt;/p&gt;

</description>
      <category>azurefunctions</category>
      <category>dotnet</category>
      <category>azure</category>
    </item>
    <item>
      <title>.NET MAUI (Cross Platform framework)</title>
      <dc:creator>Nalin Jayasinghe</dc:creator>
      <pubDate>Sat, 14 May 2022 09:40:16 +0000</pubDate>
      <link>https://dev.to/nalinj/net-maui-4g51</link>
      <guid>https://dev.to/nalinj/net-maui-4g51</guid>
      <description>&lt;p&gt;.NET MAUI stands for .NET Multi-platform App UI.&lt;/p&gt;

&lt;p&gt;.NET MAUI is a first class cross-platform framework for creating native mobile and desktop apps with C# and XAML.&lt;/p&gt;

&lt;p&gt;Using .NET MAUI We can develop apps that can run on Mobile (Android, iOS) and Desktop (macOS, Windows) from a single shared code-base.&lt;/p&gt;

&lt;p&gt;.NET MAUI is open source and is the evolution of Xamarin.Forms.&lt;/p&gt;

&lt;p&gt;.NET MAUI and Xamarin.Forms has many similarities. Xamarin.Forms need separate project for each platform. However, .NET MAUI can create multi platform apps using a single project. One of the key aim of .NET MAUI is to implement your app logic and UI layout in single code-base. Also .NET MAUI allow you to add platform-specific code and resources if necessary.&lt;/p&gt;

&lt;p&gt;Creating a cross-platform app is not easy task due to deferent OS and device specs. .NET MAUI simplified it by abstracts them into a single shared project that can target Android, iOS, macOS, and Windows.&lt;/p&gt;

&lt;p&gt;.NET MAUI single project provides the following features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A single shared project that can target Android, iOS, macOS, and Windows.&lt;/li&gt;
&lt;li&gt;A simplified debug target selection for running your .NET MAUI apps.&lt;/li&gt;
&lt;li&gt;Shared resource files within the single project.&lt;/li&gt;
&lt;li&gt;A single app manifest that specifies the app title, id, and version.&lt;/li&gt;
&lt;li&gt;Access to platform-specific APIs and tools when required.&lt;/li&gt;
&lt;li&gt;A single cross-platform app entry point.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;br&gt;
I am very excited about .NET MAUI and all the productivity and performance it will bring. I look forward to build apps using .NET MAUI and share my learnings and experiences with you all.&lt;/p&gt;

&lt;p&gt;Thanks for reading! &lt;br&gt;
Feedback is always welcome. &lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
