<?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 Venkatesh Gaddam on Medium]]></title>
        <description><![CDATA[Stories by Venkatesh Gaddam on Medium]]></description>
        <link>https://medium.com/@venkatesh29?source=rss-82292b0aa1a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*R3SciomsKpHMIpu36J9Qrw.jpeg</url>
            <title>Stories by Venkatesh Gaddam on Medium</title>
            <link>https://medium.com/@venkatesh29?source=rss-82292b0aa1a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 00:36:01 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@venkatesh29/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[Breaking Free from Secrets: Our Journey to Secure Azure Integration with Managed Identity]]></title>
            <link>https://venkatesh29.medium.com/breaking-free-from-secrets-our-journey-to-secure-azure-integration-with-managed-identity-cf3b4ea70a98?source=rss-82292b0aa1a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf3b4ea70a98</guid>
            <category><![CDATA[azure]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[azure-managed-identities]]></category>
            <category><![CDATA[cloud-services]]></category>
            <dc:creator><![CDATA[Venkatesh Gaddam]]></dc:creator>
            <pubDate>Wed, 09 Apr 2025 19:01:52 GMT</pubDate>
            <atom:updated>2025-04-09T19:01:52.284Z</atom:updated>
            <content:encoded><![CDATA[<h3>Managed Identity Integration Documentation</h3><h3>Overview</h3><p>For years, our cloud applications carried a silent burden — a vault of secrets hidden in plain sight. Connection strings, access keys, and credentials sat quietly in configuration files, dangerously exposed yet necessary for Azure services to function. Every deployment was a tightrope walk between agility and security. Rotation of secrets became a chore, often ignored. And in every pull request, we whispered silent prayers that nothing sensitive had slipped through.</p><p>This was our reality — a fragile ecosystem where the convenience of connection came at the cost of potential exposure.</p><p>Then came a shift. A new approach. One that promised a future without secrets: <strong>Managed Identity</strong>.</p><p>By allowing our apps to authenticate seamlessly with Azure resources — without ever needing a password or key — Managed Identity became our lifeline. We no longer had to manage secrets or worry about credential leakage. Our Web APIs and Azure Functions could now speak directly with Cosmos DB, Service Bus, and more — securely and silently — using their own trusted identities.</p><p>This document is a reflection of that transformation. A journey away from risk, toward a cleaner, safer, and more maintainable integration story with Azure.</p><h3>What is Managed Identity?</h3><p>Managed Identity is a feature of Azure Active Directory that allows Azure services to authenticate to other Azure services without storing credentials in your code.</p><p>There are two types:</p><p><strong>System Assigned Managed Identity (SAMI):</strong></p><ul><li>Some Azure resources, such as virtual machines allow you to enable a managed identity directly on the resource.</li></ul><p>When you enable a system-assigned managed identity:</p><ul><li>A service principal of a special type is created in Microsoft Entra ID for the identity. The service principal is tied to the lifecycle of that Azure resource. When the Azure resource is deleted, Azure automatically deletes the service principal for you.</li><li>By design, only that Azure resource can use this identity to request tokens from Microsoft Entra ID.</li><li>You authorize the managed identity to have access to one or more services.The name of the system-assigned service principal is always the same as the name of the Azure resource it’s created for. For a deployment slot, the name of its system-assigned identity is &lt;app-name&gt;/slots/&lt;slot-name&gt;.</li></ul><p><strong>User Assigned Managed Identity (UAMI):</strong></p><ul><li>You may also create a managed identity as a standalone Azure resource. You can <a href="https://learn.microsoft.com/en-us/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities?pivots=identity-mi-methods-azp">create a user-assigned managed identity</a> and assign it to one or more Azure Resources. When you enable a user-assigned managed identity:</li><li>A service principal of a special type is created in Microsoft Entra ID for the identity. The service principal is managed separately from the resources that use it.</li><li>User-assigned identities can be used by multiple resources.</li><li>You authorize the managed identity to have access to one or more services.</li></ul><h3>Why Managed Identity?</h3><ul><li>Removes the need to store secrets or credentials.</li><li>More secure and reduces risk of credential leakage.</li><li>Simplifies credential rotation.</li><li>Better for DevOps and CI/CD integrations</li></ul><h3>Implementation Steps</h3><h3>1. Create a User Assigned Managed Identity (UAMI)</h3><pre>az identity create --name my-uami --resource-group my-rg --location eastus</pre><h3>2. Assign IAM Permissions to Azure Services for UAMI</h3><p>Navigate to each resource → <strong>Access Control (IAM)</strong> → <strong>Add Role Assignment</strong>:</p><h4>Cosmos DB</h4><ul><li><strong>Role:</strong> Cosmos DB Built-in Data Contributor</li><li><strong>Assign Access To:</strong> User Assigned Managed Identity</li><li><strong>Select Member:</strong> Choose your UAMI</li></ul><h4>Service Bus</h4><ul><li><strong>Role:</strong> Azure Service Bus Data Sender (for publishing)</li><li><strong>Role:</strong> Azure Service Bus Data Receiver (for receiving)</li><li><strong>Assign Access To:</strong> User Assigned Managed Identity</li><li><strong>Select Member:</strong> Choose your UAMI</li></ul><h4>App Configuration</h4><ul><li><strong>Role:</strong> App Configuration Data Reader</li><li><strong>Assign Access To:</strong> User Assigned Managed Identity</li><li><strong>Select Member:</strong> Choose your UAMI</li></ul><h4>Azure Storage Account</h4><ul><li><strong>Role:</strong> Storage Blob Data Contributor</li><li><strong>Assign Access To:</strong> User Assigned Managed Identity</li><li><strong>Select Member:</strong> Choose your UAMI</li></ul><h4>Application Insights</h4><ul><li><strong>Role:</strong> Monitoring Reader</li><li><strong>Assign Access To:</strong> User Assigned Managed Identity</li><li><strong>Select Member:</strong> Choose your UAMI</li></ul><h4>Key Vault</h4><ul><li><strong>Role:</strong> Key Vault Secrets User</li><li><strong>Assign Access To:</strong> User Assigned Managed Identity.</li><li><strong>Select Member:</strong> Choose your UAMI.</li></ul><h3>3. Assign UAMI to App Service or Function App</h3><pre>az webapp identity assign --resource-group my-rg --name my-app --identities &quot;/subscriptions/{sub-id}/resourcegroups/my-rg/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-uami&quot;</pre><h3>4. Access Cosmos DB using UAMI in .NET</h3><pre>var client = new CosmosClient(<br>    accountEndpoint: cosmosDbEndpoint,<br>    tokenCredential: new DefaultAzureCredential(new DefaultAzureCredentialOptions<br>    {<br>        ManagedIdentityClientId = &quot;&lt;UAMI_CLIENT_ID&gt;&quot;<br>    }));</pre><h3>5. Access Service Bus using UAMI in .NET</h3><pre>var client = new ServiceBusClient(<br>    &quot;&lt;namespace&gt;.servicebus.windows.net&quot;,<br>    new DefaultAzureCredential(new DefaultAzureCredentialOptions {<br>        ManagedIdentityClientId = &quot;&lt;UAMI_CLIENT_ID&gt;&quot;<br>    }));</pre><h3>API &amp; Function App Configurations</h3><p><strong>Dependency Injection:</strong></p><ul><li>CosmosClient and ServiceBusClient are registered in Program.cs using IServiceCollection</li><li>Injected via controllers or services</li></ul><p><strong>Managed Identity Use:</strong></p><ul><li>Use DefaultAzureCredential with ManagedIdentityClientId for both Web API and Azure Function App.</li></ul><p><strong>App Configuration Access:</strong></p><ul><li>Bound using Azure App Configuration and injected via options pattern</li></ul><h3>Sample Code Overview</h3><h4>Cosmos Controller</h4><pre>[Route(&quot;api/cosmos&quot;)]<br>[ApiController]<br>public class CosmosController : ControllerBase<br>{<br>    private readonly ICosmosDbContext cosmosDbContext;<br><br>    public CosmosController(ICosmosDbContext cosmosDbContext)<br>    {<br>        this.cosmosDbContext = cosmosDbContext;<br>    }<br><br><br>    [HttpGet(&quot;read/{sku}&quot;)]<br>    public async Task&lt;IActionResult&gt; ReadItem(string sku)<br>    {<br>        JObject outputResult = new JObject();<br>        var container = cosmosDbContext.GetContainer(&quot;Products&quot;);<br>        var skuQuery = new QueryDefinition(<br>              &quot;SELECT * FROM c where c.productSku=@param&quot;)<br>            .WithParameter(&quot;@param1&quot;, sku)<br>        var iterator = container.GetItemQueryIterator&lt;JObject&gt;(skuQuery,<br>            requestOptions: new QueryRequestOptions() <br>                                { <br>                                  MaxBufferedItemCount = 1 <br>                                });<br><br>        using (iterator)<br>        {<br>            while (iterator.HasMoreResults)<br>            {<br>                var result = await iterator.ReadNextAsync(CancellationToken.None);<br>                foreach (var item in result)<br>                {<br>                    outputResult = item;<br>                }<br>            }<br>        }<br><br>        return Ok(outputResult);<br>    }<br>}</pre><h4><strong>ServiceBus Controller</strong></h4><pre>[Route(&quot;api/servicebus&quot;)]<br>[ApiController]<br>public class ServiceBusController(ServiceBusClient client,<br>                                  IConfiguration config) : ControllerBase<br>{<br>    private readonly ServiceBusClient _client = client;<br>    private readonly string _queueName = config[&quot;ServiceBus:QueueName&quot;] ?? &quot;&quot;;<br><br>    [HttpPost(&quot;publish&quot;)]<br>    public async Task&lt;IActionResult&gt; PublishMessage([FromBody] string message)<br>    {<br>        var sessionId = Guid.NewGuid().ToString();<br>        var sender = _client.CreateSender(_queueName);<br>        var serviceBusMessage = new ServiceBusMessage(message);<br>        serviceBusMessage.ApplicationProperties[&quot;MessageSessionId&quot;] = sessionId;<br>        await sender.SendMessageAsync(new ServiceBusMessage(message));<br>        return Ok($&quot;Message Sent with SessionId {sessionId}&quot;);<br>    }<br><br>    [HttpGet(&quot;receive&quot;)]<br>    public async Task&lt;IActionResult&gt; ReceiveMessage()<br>    {<br>        var receiver = _client.CreateReceiver(_queueName);<br>        var message = await receiver.ReceiveMessageAsync();<br>        if (message != null)<br>        {<br>            await receiver.CompleteMessageAsync(message);<br>            return Ok(message.ApplicationProperties[&quot;MessageSessionId&quot;]);<br>        }<br>        return NoContent();<br>    }<br>}</pre><h4>CosmosDbContext</h4><pre>public interface ICosmosDbContext<br>{<br>    Container GetContainer(string containerName);<br>}<br><br>public class CosmosDbContext : ICosmosDbContext<br>{<br>    private readonly CosmosClient _client;<br>    private readonly IConfiguration _configuration;<br><br>    public CosmosDbContext(CosmosClient client, IConfiguration configuration)<br>    {<br>        _client = client;<br>        _configuration = configuration;<br>    }<br><br>    public Container GetContainer(string containerName)<br>    {<br>        return _client.GetContainer(<br>                     _configuration[&quot;Cosmos:Database&quot;],<br>                     containerName);<br>    }<br>}</pre><h3>Program.cs Registration</h3><pre>builder.Services.AddSingleton(x =&gt; new CosmosClient(<br>    configuration[&quot;Cosmos:AccountEndpoint&quot;],<br>    new DefaultAzureCredential(new DefaultAzureCredentialOptions {<br>        ManagedIdentityClientId = configuration[&quot;AzureAd:ManagedIdentityClientId&quot;]<br>    })));<br><br>builder.Services.AddSingleton&lt;ICosmosDbContext, CosmosDbContext&gt;();<br>builder.Services.AddSingleton(x =&gt; new ServiceBusClient(<br>    configuration[&quot;ServiceBus:Namespace&quot;],<br>    new DefaultAzureCredential(new DefaultAzureCredentialOptions {<br>        ManagedIdentityClientId = configuration[&quot;AzureAd:ManagedIdentityClientId&quot;]<br>    })));</pre><h3>ARM Template</h3><pre>{<br>  &quot;$schema&quot;: &quot;https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#&quot;,<br>  &quot;contentVersion&quot;: &quot;1.0.0.0&quot;,<br>  &quot;resources&quot;: [<br>    {<br>      &quot;type&quot;: &quot;Microsoft.ManagedIdentity/userAssignedIdentities&quot;,<br>      &quot;apiVersion&quot;: &quot;2018-11-30&quot;,<br>      &quot;name&quot;: &quot;my-uami&quot;,<br>      &quot;location&quot;: &quot;[resourceGroup().location]&quot;<br>    },<br>    {<br>      &quot;type&quot;: &quot;Microsoft.Web/sites&quot;,<br>      &quot;apiVersion&quot;: &quot;2022-03-01&quot;,<br>      &quot;name&quot;: &quot;my-app&quot;,<br>      &quot;location&quot;: &quot;[resourceGroup().location]&quot;,<br>      &quot;identity&quot;: {<br>        &quot;type&quot;: &quot;UserAssigned&quot;,<br>        &quot;userAssignedIdentities&quot;: {<br>          &quot;/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.ManagedIdentity/userAssignedIdentities/my-uami&quot;: {}<br>        }<br>      },<br>      &quot;properties&quot;: {<br>        // Web app properties<br>      },<br>      &quot;dependsOn&quot;: [<br>        &quot;Microsoft.ManagedIdentity/userAssignedIdentities/my-uami&quot;<br>      ]<br>    }<br>  ]<br>}</pre><blockquote><em>Replace </em><em>{subscriptionId}, </em><em>{resourceGroup} with appropriate values.</em></blockquote><h3>Local Development</h3><blockquote><em>To run the project locally while using Managed Identity:</em></blockquote><ul><li>Use <strong>Azure CLI Credential</strong> (if signed in via az login) or</li><li>Set ManagedIdentityClientId in local.settings.json or appsettings.Development.json (to use correct UAMI in cloud, fallback in local)</li></ul><pre>{<br>  &quot;AzureAd&quot;: {<br>    &quot;ManagedIdentityClientId&quot;: &quot;&lt;UAMI_CLIENT_ID&gt;&quot;<br>  }<br>}</pre><p>In Program.cs:</p><pre>builder.Services.AddSingleton(x =&gt; new DefaultAzureCredential(<br>    new DefaultAzureCredentialOptions { ManagedIdentityClientId = configuration[&quot;AzureAd:ManagedIdentityClientId&quot;] }));</pre><h3>Extending Beyond</h3><p>The services highlighted in this document are just the beginning. Managed Identity can be used across a wide range of Azure resources — including Azure SQL Database, Azure Maps, Azure Container Registry, Azure Machine Learning, and many more. This secure authentication mechanism continues to grow in support and adoption, making it an essential tool for any secure cloud architecture.</p><h3>Conclusion</h3><p>Our transformation was more than a technical upgrade — it was a shift in mindset. By embracing Managed Identity, we freed ourselves from the long-standing pitfalls of secret sprawl and brittle credential management. What once required careful handling of keys and secrets is now streamlined, secure, and maintainable.</p><p>Through this journey, we enabled our Web API and Azure Function App to integrate confidently with Azure Cosmos DB, Service Bus, App Configuration, and other services — without ever exposing a single secret. Managed Identity not only secured our ecosystem but also empowered our developers to focus on building, not worrying.</p><p>This approach is not just a best practice; it’s the new standard for secure, scalable, and cloud-native development.</p><p>Happy Coding!!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf3b4ea70a98" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Use Azure App Configuration with Shared Settings in ASP.NET Core API and Azure Functions]]></title>
            <link>https://venkatesh29.medium.com/use-azure-app-configuration-with-shared-settings-in-asp-net-core-api-and-azure-functions-7794b10b6069?source=rss-82292b0aa1a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/7794b10b6069</guid>
            <category><![CDATA[configuration-management]]></category>
            <category><![CDATA[azure-services]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[appconfig]]></category>
            <category><![CDATA[azure-functions]]></category>
            <dc:creator><![CDATA[Venkatesh Gaddam]]></dc:creator>
            <pubDate>Sun, 15 Sep 2024 16:35:10 GMT</pubDate>
            <atom:updated>2024-09-15T16:35:10.579Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello, everyone! Welcome back to the blog. Today, I’m excited to share a solution that simplifies the often tedious process of managing configuration settings in distributed projects. If you’ve ever found yourself waiting on configuration files from colleagues before you could begin debugging, this approach will help you bypass those delays and get straight into coding.</p><p>In this article, we’ll explore how to seamlessly integrate Azure App Configuration into your project, enabling centralized management of settings and feature flags. Before we dive in, a basic understanding of C# and Azure services will be helpful.</p><p>Let’s get started!</p><p>In modern cloud-native applications, efficient configuration management is crucial, especially when you’re working with multiple environments or deploying across different regions. One of the most effective ways to handle this complexity is by using <strong>Azure App Configuration</strong>. In this article, we’ll explore how to integrate Azure App Configuration into two projects: <strong>FarmerMarket.API</strong> and <strong>FarmerMarket.Functions</strong>.</p><p>We will also place the shared configuration settings in a common folder so that both projects can use them effectively, minimizing code duplication and ensuring consistency.</p><h3><strong>Why Azure App Configuration?</strong></h3><p>Azure App Configuration helps centralize application configuration and feature management, reducing the risks of hardcoding configuration values. The key features of Azure App Configuration include:</p><ul><li>Centralized configuration for multiple applications.</li><li>Dynamic configuration updates without redeploying your application.</li><li>Built-in integration with Azure Key Vault for sensitive data.</li><li>Feature management for feature toggling.</li></ul><p>In this guide, we’ll cover:</p><ol><li>Setting up Azure App Configuration.</li><li>Configuring the FarmerMarket.API and FarmerMarket.Functions projects.</li><li>Sharing common settings between API and Function apps.</li><li>Writing unit tests for the integration.</li></ol><p>As the Initial Setup, We write the Common Code which is required for the AppConfig Setup in both API and Azure Function.To achieve this, we need to implement two extension methods. One for Configuring AzureAppConfig and another for setting up Injecting the Settings to use them via Options Pattern in the resepctive Service Methods.</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Text;<br>using System.Threading.Tasks;<br>using Azure.Identity;<br>using Microsoft.Azure.Functions.Extensions.DependencyInjection;<br>using Microsoft.Extensions.Configuration;<br>using Microsoft.Extensions.Configuration.AzureAppConfiguration;<br>using Microsoft.Extensions.DependencyInjection;<br>using Microsoft.Extensions.Hosting;<br><br>namespace FarmerMarket.Common.Extensions;<br>public static class AppConfigurationExtensions<br>{<br>    public static IHostBuilder AddAzureAppConfigForApi(this IHostBuilder builder)<br>    {<br>        builder.ConfigureAppConfiguration((context, config) =&gt;<br>        {<br>            var settings = config.Build();<br><br>            config.AddAzureAppConfiguration(options =&gt; ConfigureAppConfigService(options, settings));<br>        });<br>        return builder;<br>    }<br><br>    public static IConfigurationBuilder AddAzureAppConfigForFunctions(this IConfigurationBuilder builder)<br>    {<br>        var config = builder.Build();<br><br>        builder.AddAzureAppConfiguration(options =&gt; ConfigureAppConfigService(options, config));<br><br>        return builder;<br>    }<br><br>    private static void ConfigureAppConfigService(AzureAppConfigurationOptions options, IConfigurationRoot iConfigRoot)<br>    {<br>        options.Connect(iConfigRoot[AppConstants.AZURE_APP_CONFIG_KEY])<br>                               .Select(KeyFilter.Any)<br>                               .UseFeatureFlags(featureFlagOptions =&gt; featureFlagOptions.Select(KeyFilter.Any))<br>                               .ConfigureRefresh(refreshOptions =&gt;<br>                                    refreshOptions.Register(AppConstants.SENTINAL, refreshAll: true)<br>                                                  .SetCacheExpiration(TimeSpan.FromMinutes(1)));<br><br>        options.ConfigureKeyVault(keyVaultOptions =&gt; keyVaultOptions.SetCredential(new DefaultAzureCredential()));<br>    }<br><br>}</pre><pre><br>public static class ServiceCollectionExtensions<br>{<br>    public static IServiceCollection RegisterSettings&lt;TSettings, TValidator&gt;(this IServiceCollection services, IConfiguration configuration)<br>        where TSettings : class<br>        where TValidator : class, IValidator&lt;TSettings&gt;<br>    {<br>        // Bind settings from the configuration<br>        services.Configure&lt;TSettings&gt;(configuration.GetSection(typeof(TSettings).GetProperty(&quot;SectionName&quot;)?.GetValue(null)?.ToString() ?? typeof(TSettings).Name));<br><br>        // Add FluentValidation for the settings class<br>        services.AddSingleton&lt;IValidator&lt;TSettings&gt;, TValidator&gt;();<br><br>        // Add the generic validation for the settings class<br>        services.AddTransient&lt;IValidateOptions&lt;TSettings&gt;, ValidateSettings&lt;TSettings&gt;&gt;();<br><br>        return services;<br>    }<br><br>    public static IHostBuilder RegisterServicesForApi(this IHostBuilder builder)<br>    {<br>        builder.ConfigureServices((context, services) =&gt; RegisterServices( context.Configuration, services));<br>        return builder;<br>    }<br><br>    public static IFunctionsHostBuilder RegisterServicesForFunctions(this IFunctionsHostBuilder builder)<br>    {<br>        var context = builder.GetContext();<br>        RegisterServices(context.Configuration, builder.Services);<br>        return builder;<br>    }<br><br>    private static void RegisterServices(IConfiguration configuration, IServiceCollection services)<br>    {<br>        services.RegisterSettings&lt;CosmosSettings, CosmosSettings.CosmosSettingsValidator&gt;(configuration);<br>        services.RegisterSettings&lt;StorageSettings, StorageSettings.StorageSettingsValidator&gt;(configuration);<br>        services.RegisterSettings&lt;TranslationApiSettings, TranslationApiSettings.TranslationApiSettingsValidator&gt;(configuration);<br>        services.RegisterSettings&lt;ApplicationSettings, ApplicationSettings.ApplicationSettingsValidator&gt;(configuration);<br>        services.AddFeatureManagement();<br>    }<br>}</pre><blockquote>If you have n number of appsettings in your project, then the GenericMethod RegisterSettings will be really of great help as it will reduce the load of we specifically injecting and configuring the settings.</blockquote><blockquote>Another advantage is the <em>SectionName</em> property in all the settings classes which allows for easier and more centralized management of configuration sections. By including the section name within the settings class itself, you avoid hardcoding the section name multiple times, making it easier to bind configurations, especially if your app reads from multiple sources like Azure App Configuration, Key Vault, or local JSON files.</blockquote><h3>Validate Settings</h3><p>If you observe carefully, I have added Fulent ValidationRules to the Settings Classes just to ensure that the data we store in the Config Explorer is valid.Feel free to add your own custom validations with the help of the Generic <strong>ValidateSettings </strong>class like this:</p><pre>using System.Configuration;<br>using System.Reflection;<br>using FluentValidation;<br>using Microsoft.Extensions.Configuration;<br>using Microsoft.Extensions.DependencyInjection;<br>using Microsoft.Extensions.Hosting;<br>using Microsoft.Extensions.Options;<br>using Microsoft.FeatureManagement;<br><br>namespace FarmerMarket.Common.Extensions;<br><br>public class ValidateSettings&lt;T&gt; : IValidateOptions&lt;T&gt;<br>    where T : class<br>{<br>    private readonly IValidator&lt;T&gt; validator;<br><br>    public ValidateSettings(IValidator&lt;T&gt; validator) =&gt; this.validator = validator;<br><br>    public ValidateOptionsResult Validate(string name, T options)<br>    {<br>        var validationResult = validator.Validate(options);<br><br>        if (validationResult.IsValid)<br>        {<br>            return ValidateOptionsResult.Success;<br>        }<br><br>        var errors = validationResult.Errors.Select(e =&gt; e.ErrorMessage);<br>        return ValidateOptionsResult.Fail(errors);<br>    }<br>}</pre><p>With this, if the data is invalid, your app wont start at the first place which gives us a good idea of what and how we should store our settings.</p><p>The Common/Settings folder contains the settings that will be used across both projects.</p><p><strong>Step 1: Define the Shared Settings Classes</strong></p><p>Create a couple of Common Settings files in the Common/Settings folder, which will hold our shared configuration. Here in my Project I use NoSqlDb and also Blob Storage. Therefore I have used these Settings class files. Feel free to create your own custom settings files for your module/feature/application.</p><pre>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Text;<br>using System.Threading.Tasks;<br>using FluentValidation;<br><br>namespace FarmerMarket.Common.Configuration.Settings;<br>public class NoSqlDbSettings<br>{<br>    public string CosmosConnectionString { get; set; } = default!;<br>    public static string SectionName =&gt; &quot;CommonSettings:CosmosSettings&quot;;<br>    public class NoSqlDbSettingsValidator : AbstractValidator&lt;NoSqlDbSettings&gt;<br>    {<br>        public NoSqlDbSettingsValidator() =&gt; RuleFor(x =&gt; x.CosmosConnectionString).NotEmpty().WithMessage(&quot;CosmosConnectionString must not be empty.&quot;);<br>    }<br>}</pre><pre><br>using System;<br>using System.Collections.Generic;<br>using System.Linq;<br>using System.Text;<br>using System.Threading.Tasks;<br>using FluentValidation;<br><br>namespace FarmerMarket.Common.Configuration.Settings;<br>public class StorageSettings<br>{<br>    public string BlobConnectionString { get; set; } = default!;<br>    public string BlobContainerName { get; set; } = default!;<br>    public static string SectionName =&gt; &quot;CommonSettings:StorageSettings&quot;;<br>    public string SizeLimitBytes { get; set; } = default!;<br>    public string SqlDbConnectionString { get; set; } = default!;<br><br>    public class StorageSettingsValidator : AbstractValidator&lt;StorageSettings&gt;<br>    {<br>        public StorageSettingsValidator()<br>        {<br>            RuleFor(x =&gt; x.BlobConnectionString).NotEmpty().WithMessage(&quot;BlobConnectionString must not be empty.&quot;);<br>            RuleFor(x =&gt; x.SqlDbConnectionString).NotEmpty().WithMessage(&quot;SqlDbConnectionString must not be empty.&quot;);<br>        }<br>    }<br>}</pre><p><strong>Step 2: Using the Shared Extension in </strong><strong>FarmerMarket.API</strong></p><p>We’ll now integrate Azure App Configuration into the API project.</p><p>In FarmerMarket.API, update the Program.cs call the Extension Method to configure the AzureAppConfig.</p><pre>internal static IHostBuilder CreateHostBuilder(string[] args) =&gt;<br>    Host.CreateDefaultBuilder(args) <br>        .AddAzureAppConfigForApi()<br>        .RegisterServicesForApi();</pre><p><strong>Step 3: Using the Shared Extension in </strong><strong>FarmerMarket.Functions</strong></p><p>For the <strong>FarmerMarket.Functions</strong> project, use the same extension method inside the FunctionsStartup class:</p><pre>public override void ConfigureAppConfiguration(IFunctionsConfigurationBuilder builder)<br>{<br>    builder.ConfigurationBuilder.AddAzureAppConfigForFunctions();<br>}</pre><p><strong>Step 4: Testing the Shared Configuration Logic</strong></p><p><strong>Web.API</strong></p><p>Create an API Controller just to test your settings. Also, Remove the properties that you are gonna test from your appsettings.json file.</p><pre>using FarmerMarketAPI.Data.Repository;<br>using Microsoft.AspNetCore.Http;<br>using Microsoft.AspNetCore.Mvc;<br><br>namespace FarmerMarketAPI.CheckoutSystem.Controllers<br>{<br>    [Route(&quot;api/[controller]&quot;)]<br>    [ApiController]<br>    public class ProductsController : ControllerBase<br>    {<br>        private readonly CosmosSettings noSqlSettings;<br>        private readonly IFeatureManager featureManager;<br>        private readonly IProductRepository productRepository;<br>        public ProductsController(IProductRepository productRepository,IOptionsSnapshot&lt;CosmosSettings&gt; noSqlSettings, IFeatureManager featureManager)<br>        {<br>            this.noSqlSettings= itemMasterSettings.Value;<br>            this.featureManager = featureManager;<br>            this.productRepository = productRepository;<br>        }<br><br>        [AllowAnonymous]<br>        [HttpGet]<br>        public async Task&lt;IActionResult&gt; Get() =&gt;<br>        await featureManager.IsEnabledAsync(&quot;IsAlternatesRawMessageEnabled&quot;)<br>          ? Ok(new<br>          {<br>            appSettings.ApplicationName,<br>            itemMasterSettings.CosmosConnectionString<br>          })<br>          : (IActionResult)Ok(&quot;Beta feature is disabled.&quot;);<br>}</pre><p>This way, we can test our AzureAppConfig Setup in API.</p><p><strong>Functions</strong></p><p>We will write a sample TimerTrigger Function to test the config setup in Azure Functions.</p><pre>public class TimerFunction<br>{<br>    private readonly NoSqlDbSettings _settings;<br><br>    public TimerFunction(IOptions&lt;NoSqlDbSettings&gt; settings)<br>    {<br>        _settings = settings.Value;<br>    }<br><br>    [FunctionName(&quot;TimerFunction&quot;)]<br>    public void Run([TimerTrigger(&quot;0 */5 * * * *&quot;)] TimerInfo myTimer, ILogger log)<br>    {<br>        log.LogInformation($&quot;Cosmos Connection String: {_settings.CosmosSettings.CosmosConnectionString}&quot;);<br>    }<br>}</pre><h3>Unit Testing</h3><p>To ensure that our settings are correctly loaded, we can write a unit test using XUnit.</p><pre>public class AzureAppConfigIntegrationTests<br>{<br>    private const string COMMON_SETTINGS_SECTION_NAME = &quot;CommonSettings&quot;;<br>    private const string SENTINAL_KEY = &quot;FarmerMarket:Sentinel&quot;;<br>    private readonly IConfiguration configuration;<br><br>    public AzureAppConfigIntegrationTests()<br>    {<br>        // Mock configuration values using in-memory collection<br>        var inMemorySettings = new Dictionary&lt;string, string&gt;<br>        {<br>            // Mocking Azure App Configuration settings<br>            { $&quot;{COMMON_SETTINGS_SECTION_NAME}:CosmosSettings:CosmosConnectionString&quot;, &quot;cosmosconnectionstring&quot; },<br>            { $&quot;{COMMON_SETTINGS_SECTION_NAME}:StorageSettings:BlobConnectionString&quot;, &quot;blobstorageconnectionstring&quot; },<br>            { $&quot;{COMMON_SETTINGS_SECTION_NAME}:StorageSettings:BlobContainerName&quot;, &quot;blobContainerNameHere&quot; },<br>        };<br><br>        // Build configuration with mocked in-memory data<br>        configuration = new ConfigurationBuilder()<br>            .AddInMemoryCollection(inMemorySettings) // Mocking the Azure App Configuration<br>            .Build();<br>    }<br><br>    [Fact]<br>    public void CommonSettings_Should_BeBound_From_MockedConfig()<br>    {<br>        // Arrange<br>        var services = new ServiceCollection();<br>        services.AddOptions();<br><br>        // Bind the mocked configuration<br>        services.Configure&lt;CommonSettings&gt;(configuration.GetSection(COMMON_SETTINGS_SECTION_NAME));<br>        var serviceProvider = services.BuildServiceProvider();<br><br>        // Act<br>        var options = serviceProvider.GetRequiredService&lt;IOptions&lt;CommonSettings&gt;&gt;().Value;<br><br>        // Assert<br>        Assert.NotNull(options);<br>        Assert.NotNull(options.CosmosSettings);<br>        Assert.NotNull(options.StorageSettings);<br>        Assert.Equal(&quot;cosmosconnectionString&quot;, options.CosmosSettings.CosmosConnectionString);<br>        Assert.Equal(&quot;blobstorageconnectionstring&quot;, options.StorageSettings.BlobConnectionString);<br>        Assert.Equal(&quot;blobContainerNameHere&quot;, options.StorageSettings.BlobContainerName);<br>    }<br>}</pre><p>The final Project structure is:</p><pre>FarmerMarket/<br>    ├── Common/<br>    │   ├── Extensions/<br>    │   │   └── AzureAppConfigurationExtensions.cs  <br>    |   |   └── ServiceCollectionExtensions.cs<br>    │   └── Settings/<br>    │       ├── CosmosSettings.cs<br>    │       ├── StorageSettings.cs<br>    │       └── CommonSettings.cs<br>    ├── FarmerMarket.API/<br>    │   └── Program.cs<br>    ├── FarmerMarket.Functions/<br>    │   └── Startup.cs</pre><p>Using Azure App Configuration for both <strong>FarmerMarket.API</strong> and <strong>FarmerMarket.Functions</strong> simplifies managing configurations across multiple projects. With shared settings and dynamic refresh capabilities, you ensure consistency and flexibility without redundant configurations. The approach described above can easily be extended to add more services, settings, or features while keeping everything centralized.</p><p>Azure App Configuration is a powerful tool for developers building cloud-native applications, and integrating it with projects like <strong>FarmerMarket.API</strong> and <strong>FarmerMarket.Functions</strong> helps streamline configuration management while making your code more maintainable and scalable.</p><p>Feel free to explore more advanced options, like custom feature flags, integration with Key Vault for secrets, and other configurations to further optimize your cloud applications!</p><p>Thanks for reading this article till the end. Happy Coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7794b10b6069" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Calling a WebAPI from another .NET Application Using HTTPCLIENT]]></title>
            <link>https://venkatesh29.medium.com/calling-a-webapi-from-another-net-application-using-httpclient-1db2dd1a91b?source=rss-82292b0aa1a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/1db2dd1a91b</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[http-client]]></category>
            <category><![CDATA[httpclientmodule]]></category>
            <category><![CDATA[rest-api]]></category>
            <dc:creator><![CDATA[Venkatesh Gaddam]]></dc:creator>
            <pubDate>Mon, 08 May 2023 07:45:09 GMT</pubDate>
            <atom:updated>2023-08-30T05:23:25.183Z</atom:updated>
            <content:encoded><![CDATA[<h3>Calling a WebAPI from another .NET Application Using HTTPCLIENT</h3><p>Hello guys,</p><p>In this article I just want to explain you on a simple issue that everyone will face while they were in the initial stages of .Net Development Career.</p><p>Whenever a developer is working on microservices a question would come up in their mind. That is how do we call another service and use that data here for our further processing. To put an end to it one of the approaches is by doing an API-to-API call i.e. we call another API from our API with the help of Web API Client Libraries like <a href="https://restsharp.dev/">RESTSHARP</a> &amp;&amp; <a href="https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-8.0">HTTPCLIENT </a>to consume a <a href="https://en.wikipedia.org/wiki/Representational_state_transfer#RESTful_web_services">RESTful</a> service.</p><p>So, In this Article, I would show you how to use HttpClient C# as a bridge between two Service calls.</p><p>I have a requirement to publish a message to the queue from my API Service A. But this implementation is being done in another API B. Both are in .Net 6 and C# is the Programming Language.</p><p>In order to call this API from API A, I have written the below code.</p><blockquote>FYI, mine is a post request so I have called client.postasync(). HttpClient provides us different methods for our REST Operations. Please read this <a href="https://learn.microsoft.com/en-us/dotnet/api/system.net.http.httpclient?view=net-8.0">Documentation</a>.</blockquote><pre><br>// The JSON Object which contains information about the message and it&#39;s source.<br>// My API input Object.<br>SendMessageRequest requestDto = new SendMessageRequest()<br>                                {<br>                                  IntegrationName = &quot;Demo&quot;,<br>                                  MessageBody = &quot;Sample Message&quot;,<br>                                  RequestType = &quot;Integration&quot;,<br>                                  ResponseType = &quot;IntegrationResponse&quot;<br>                                };<br><br>var client = new HttpClient();<br>client.BaseAddress = new Uri(&quot;https://localhost:5001/&quot;);<br>client.DefaultRequestHeaders.Accept.Clear();<br>client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(&quot;application/json&quot;));<br>HttpContent httpContent = new StringContent(JsonConvert.SerializeObject(requestDto), Encoding.UTF8, &quot;application/json&quot;);<br>var result = await client.PostAsync(&quot;api/Story/ExecuteStory&quot;, httpContent);<br><br> if (result.IsSuccessStatusCode)<br> {<br>   var response = await result.Content.ReadAsStringAsync();<br>   //Do the needful with the response object.<br> }</pre><p>Likewise, with the help of HttpClient in C# we can consume a REST API from another .NET Application.</p><p>Thank you for reading this Article.</p><p><em>HAPPY CODING.</em></p><p>STAY SAFE!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1db2dd1a91b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[DatePicker in Asp.Net MVC Using Bootstrap and jQuery]]></title>
            <link>https://venkatesh29.medium.com/datepicker-in-asp-net-mvc-using-bootstrap-and-jquery-b6d49f10f845?source=rss-82292b0aa1a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b6d49f10f845</guid>
            <category><![CDATA[aspnet-mvc]]></category>
            <category><![CDATA[bootstrap]]></category>
            <category><![CDATA[datepicker]]></category>
            <category><![CDATA[jquery-ui]]></category>
            <dc:creator><![CDATA[Venkatesh Gaddam]]></dc:creator>
            <pubDate>Tue, 29 Mar 2022 16:47:49 GMT</pubDate>
            <atom:updated>2022-03-29T16:47:49.377Z</atom:updated>
            <content:encoded><![CDATA[<p>Hello everyone!!!</p><p>In this article, I would be discussing about how to add DatePicker in your View in the MVC Application using Bootstrap and jQuery. <br>I am assuming you have knowledge on how to use jQuery , Bootstrap and downloading them in your application or a HTML page.<br>Ok, Let’s move on….</p><p>I have created a WEB APPLICATION in my Visual Studio 2019 using .NET 5.0 and MVC. Just for the article sake I would be showing only the Datepicker Control in the Web application I am going to create.</p><p>After creating the Web Application the Folder Structure would be coming up as shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/715/1*4UGhFP0sUSrQj3qO4bmXRQ.png" /></figure><p>I have created a View <strong>DatePicker.cshtml.</strong></p><p>In the View, add the below code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GWBBgGwD3yqhEO1kv0T4AQ.png" /><figcaption>DatePicker Code</figcaption></figure><p>Don’t forget to add the dependencies (e.g. jQuery, jQuery UI, CSS) as shown below</p><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;//code.jquery.com/ui/1.13.1/themes/base/jquery-ui.css&quot;&gt;</pre><pre>&lt;script src=&quot;https://code.jquery.com/jquery-3.6.0.js&quot;&gt;&lt;/script&gt;</pre><pre>&lt;script src=&quot;https://code.jquery.com/ui/1.13.1/jquery-ui.js&quot;&gt;&lt;/script&gt;</pre><p>Don’t forget to add the Latest versions of the above dependencies in order to stay up-to-date.</p><p>You can play with the datePicker with the additional options which are mentioned in the jQuery API official documentation as given below</p><p><a href="https://api.jqueryui.com/datepicker/#option-defaultDate">Datepicker Widget</a></p><p>Run the Application (Press F5 in the Visual studio).</p><p>End Result :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cUHC49kD0dNyW6uwJbQi-w.png" /><figcaption>Date Picker using Bootstrap &amp; jQuery</figcaption></figure><p>And that’s it…….🙂</p><p>Thank you for reading this short article.</p><p>Happy Coding 😉😉😉😉😉</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b6d49f10f845" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying Multiple Lambda Functions under a Single Lambda Project]]></title>
            <link>https://venkatesh29.medium.com/deploying-multiple-lambda-functions-under-a-single-lambda-project-b0bfd2f87f1e?source=rss-82292b0aa1a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b0bfd2f87f1e</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[lambda]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Venkatesh Gaddam]]></dc:creator>
            <pubDate>Sat, 07 Aug 2021 13:45:16 GMT</pubDate>
            <atom:updated>2021-08-07T13:48:48.870Z</atom:updated>
            <content:encoded><![CDATA[<p>In this Article I am going to explain how to write, test and deploy multiple Lambda Functions with the help of one single Lambda Project.</p><p>Here, I will be creating three Lambda Functions to demonstrate about the topic. So, Let’s Start Coding.</p><p>Prerequisites needed to implement this are AWS Toolkit for Visual Studio , AWS Account &amp; Visual Studio (Whichever version which supports AWS &amp; .NET Core)</p><p><strong>Step 1:</strong></p><p>If you are aware of setting up an AWS Profile in your Visual Studio, then please proceed to Step 2.</p><ol><li>Install AWS Toolkit for Visual Studio. I am using Visual Studio 2019 install it from <a href="https://marketplace.visualstudio.com/items?itemName=AmazonWebServices.AWSToolkitforVisualStudio2017">MarketPlace</a>.</li></ol><p>2. Once you install the AWS Toolkit it should appear in Visual studio as the below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/289/1*KPOKD_C8zzF9XJ6itEdbhg.png" /></figure><p>3. Click on AWS Explorer and Add a user Profile (i.e. The Access Key and Secret Key of your AWS IAM User) as shown in the pic below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/246/1*pQntC7-gOp8VTpI_L_tA6A.png" /></figure><p>4. Click on Ok. Now we are ready to get going with our Lambda Functions.</p><p><strong>Step 2:</strong></p><ol><li>Open Visual Studio &amp; create a new Lambda Project in .Netcore</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*fnClMk0TD2W4J2C7BZvn4A.png" /></figure><p>2. Provide a Name to it and Proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*2MXBZ4mZpgFZhaTlwgBdcg.png" /></figure><p>3. For simplicity, I have selected Empty Function Template ( you are free to use whatever is feasible for you)</p><p>4. Create a Class to send the inputVariables for testing. Name it as InputModel</p><pre>public class InputModel</pre><pre>{</pre><pre>public int Input1 { get; set; }</pre><pre>public int Input2 { get; set; }</pre><pre>}</pre><p>5. Modify your Function.cs class like below.</p><pre>public class Function</pre><pre>{</pre><pre>public int AddNumbers(InputModel input, ILambdaContext context)</pre><pre>{</pre><pre>Console.WriteLine($”This is First Lambda Function Log. We are adding {input.input1}, {input.input2}.”);</pre><pre>return input.input1 + input.input2;</pre><pre>}</pre><pre>public int SubtractNumbers(InputModel input, ILambdaContext context)</pre><pre>{</pre><pre>Console.WriteLine($”This is Second Lambda Function Log. We are Subtracting {input.input1}, {input.input2}.”);</pre><pre>return input.input1 — input.input2;</pre><pre>}</pre><pre>public int MultiplyNumbers(InputModel input, ILambdaContext context)</pre><pre>{</pre><pre>Console.WriteLine($”This is Third Lambda Function Log. We are multiplying {input.input1}, {input.input2}.”);</pre><pre>return input.input1 * input.input2;</pre><pre>}</pre><pre>}</pre><p>6. Now we have 3 functions in a single Lambda Project ready to test. But, they are not yet ready to get deployed all at a time. Here, Serverless.template will come to our rescue. Add Serverless.template file by right click on the Project and Add Serverless.template.</p><p>7. My Resources section in serverless.template looks like this.</p><pre>{<br>  &quot;AWSTemplateFormatVersion&quot; : &quot;2010-09-09&quot;,<br>  &quot;Transform&quot; : &quot;AWS::Serverless-2016-10-31&quot;,<br>  &quot;Description&quot; : &quot;Starting template for an AWS Serverless Application.&quot;,<br>  &quot;Parameters&quot; : {<br>  },<br>  &quot;Resources&quot; : {<br>    &quot;AddFunction&quot; : {<br>      &quot;Type&quot; : &quot;AWS::Serverless::Function&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;Handler&quot;: &quot;MmultipleLambdaSolution::MmultipleLambdaSolution.Function::AddNumbers&quot;,<br>        &quot;FunctionName&quot; : &quot;AdditionLambda&quot;,<br>        &quot;Runtime&quot;: &quot;dotnetcore3.1&quot;,<br>        &quot;CodeUri&quot;: &quot;&quot;,<br>        &quot;Description&quot;: &quot;This is an Addition Function deployed under Multiple Lambda in a single Solution Topic&quot;,<br>        &quot;MemorySize&quot;: 256,<br>        &quot;Timeout&quot;: 30,<br>        &quot;Role&quot;: null,<br>        &quot;Policies&quot;: [ &quot;AWSLambda_FullAccess&quot; ]<br>      }<br>    },<br>    &quot;SubtractFunction&quot; : {<br>      &quot;Type&quot; : &quot;AWS::Serverless::Function&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;Handler&quot;: &quot;MmultipleLambdaSolution::MmultipleLambdaSolution.Function::SubtractNumbers&quot;,<br>        &quot;FunctionName&quot; : &quot;SubtractLambda&quot;,<br>        &quot;Runtime&quot;: &quot;dotnetcore3.1&quot;,<br>        &quot;CodeUri&quot;: &quot;&quot;,<br>        &quot;Description&quot;: &quot;This is an SubtractNumbers Function deployed under Multiple Lambda in a single Solution Topic&quot;,<br>        &quot;MemorySize&quot;: 256,<br>        &quot;Timeout&quot;: 30,<br>        &quot;Role&quot;: null,<br>        &quot;Policies&quot;: [ &quot;AWSLambda_FullAccess&quot; ]<br>      }<br>    },<br>    &quot;MultiplyFunction&quot; : {<br>      &quot;Type&quot; : &quot;AWS::Serverless::Function&quot;,<br>      &quot;Properties&quot;: {<br>        &quot;Handler&quot;: &quot;MmultipleLambdaSolution::MmultipleLambdaSolution.Function::MultiplyNumbers&quot;,<br>        &quot;FunctionName&quot; : &quot;MultiplyLambda&quot;,<br>        &quot;Runtime&quot;: &quot;dotnetcore3.1&quot;,<br>        &quot;CodeUri&quot;: &quot;&quot;,<br>        &quot;Description&quot;: &quot;This is an MultiplyNumbers Function deployed under Multiple Lambda in a single Solution Topic&quot;,<br>        &quot;MemorySize&quot;: 256,<br>        &quot;Timeout&quot;: 30,<br>        &quot;Role&quot;: null,<br>        &quot;Policies&quot;: [ &quot;AWSLambda_FullAccess&quot; ]<br>      }<br>    }<br>  },<br>  &quot;Outputs&quot; : {}<br>}</pre><p><strong>Step 3</strong></p><ol><li>Publish Lambda.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*mZSsMxc_OKrDcYp16G0Qlg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*Eh9rQnA2NIDgzY-ZBq_fGw.png" /></figure><p>2. Test the Lambda Function either locally or through AWS Console.</p><p><strong>Summary</strong></p><p>With this we came to know that we can write all the Logic and common functionalities of Lambda Functions working on one Entity. Hope you all Learned a new thing today.</p><p>Happy Coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b0bfd2f87f1e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database Scalability and Availability : Introduction to Amazon RDS Proxy]]></title>
            <link>https://venkatesh29.medium.com/database-scalability-and-availability-introduction-to-amazon-rds-proxy-2f5a6bd03bea?source=rss-82292b0aa1a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f5a6bd03bea</guid>
            <category><![CDATA[amazon-rds]]></category>
            <category><![CDATA[database-scalability]]></category>
            <category><![CDATA[availability]]></category>
            <category><![CDATA[failover]]></category>
            <dc:creator><![CDATA[Venkatesh Gaddam]]></dc:creator>
            <pubDate>Sun, 27 Jun 2021 17:23:39 GMT</pubDate>
            <atom:updated>2021-06-27T17:23:39.539Z</atom:updated>
            <content:encoded><![CDATA[<h3>Database Scalability and Availability : Introduction to Amazon RDS Proxy</h3><p>In this article, I am going to explain how to improve Database Scalability and Availability with the help of Amazon RDS Proxy.</p><p>Many applications including modern day serverless architectures allows application to scale seamlessly and it opens and close large number of connections to the backend database and exhausting its resources. There are 3 major issues which needs a bigger attention in modern day Large Scale Distributed Systems. They are:</p><p>· Scalability</p><p>· Availability</p><p>· Security</p><p>In this article, I am going to explain how AWS RDS Proxy helps to overcome these problems. Let’s Dive In.</p><p>Amazon RDS is a managed relational Database as a Service with the choice of all the popular DB Engines both on open source and commercial. As of today, RDS has over a Decade of experience in operating and scaling the DB workloads for its customers in the cloud. Some of the Benefits of using Amazon RDS are:</p><p><strong>Ease of Administration:</strong></p><p>With the help of RDS now it has become easy to manage and scale the Database and allowing us to focus on the business logic instead of worrying about the INFRA. RDS easily deploy and maintain Hardware, OS and DB Software. It has inbuilt features like DB Monitoring etc.</p><p><strong>Performant and Scalable:</strong></p><p>Scale the compute and storage with a few clicks.</p><p><strong>Available and Durable:</strong></p><p>Automatic multi-AZ Replication, Automated snapshots, backup and failover.</p><p><strong>Security:</strong></p><p>Data Encryption at rest and Transit which makes RDS very effective.</p><p><strong>Use case of Building RDS Proxy:</strong></p><p>As most of the modern-day applications are using microservice architectures which allows applications to scale without any issues. For example, An AWS Lambda functions might scale up to 100000 very easily but think of these lambda functions which will be invoking hundreds or may be thousands of connections to the Database which makes the DB instance use its resources to manage these connections rather than work on the queries which will eventually decrease the performance of the Database.</p><p>All the applications currently want to have high availability and ability to handle the transient database failures and these transient failures are common in cloud environments and these failures are greatly minimized in RDS and aurora and it automatically detects the transient failures and perform the failover without any manual interventions even though the failover time is very fast in aurora most of the applications as I recommend to handle it and the failures with the less are no interruption at all and then application as a requirement of having more security control so that they can maintain the better security access to the database.</p><p><strong>Solutions Other Than RDS Proxy:</strong></p><p>1. Over Provisioning of Resources (Provisioning the Db instance which has High Compute Power and memory Resources to handle Connections as well the Queries)</p><p>2. Maintaining Highly complex code to overcome the Transient Db Failures.</p><p>3. Self-Managed Proxy Solution which will be the face of every DB Request which makes our architecture more complex as we need to focus more on making our proxy solution highly available. Maintenance is also a burden for this kind of solutions.</p><p><strong>Amazon RDS Proxy: Skip the Heavy Lifting</strong></p><p>Solving the above Problems RDS Proxy enters the RDS arena by providing fully managed and highly available database proxy for Amazon RDS. It pools and shares the Db Connections to make the application more scalable more resilient and highly secure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*humSNFsJrHEnxqNW-8noPg.png" /><figcaption>High Level Overview of RDS Proxy</figcaption></figure><p>RDS Proxy has come up with some great features.</p><p><strong>Fully Managed:</strong></p><p>No need to deploy RDS Proxy as it a fully managed service by Amazon. It is highly compatible with MySQL and POSTGRESQL. if you are using MYSQL or POSTGRESQL in your database you just need to change the database endpoint to the RDS proxy in your application and you’re good to go.</p><p><strong>Connection Pooling:</strong></p><p>RDS proxy performance connection pooling with a multiplexing it means whenever the database connections is not actively executing we switch it to another client connections and do the work so this helps to minimize the amount of connections that you open to the backend database which in turn reduces the CPU and memory consumption of your database.</p><p><strong>Fast and Seamless Failovers:</strong></p><p>We might know that the failover in aurora is very fast it typically take less than 30 seconds and during this process all the application connections get dropped because DB instance will go through the reboot so the application will have to re-establish the connection to the backend database again but when connecting to RDS proxy will preserve non-active connections as the failover happening there and it will direct the connection to the newly promoted instance when it becomes available an RDS proxy aware of the underlying instance so it is very fast in directing these role changes and it’s not relying on DNS so don’t need to worry about DNS caching or downstream TTL delays because of that it is able to provide up to 66 percent faster failover.</p><p><strong>Scalability:</strong></p><p>Let’s Dive Deeper into How RDS Proxy helps applications to scale better. RDS proxy perform connection polling which minimize the number of connections that you open to the backend database. For example MYSQL uses one thread per connections when you open 100 connections directly to the MYSQL instance it creates like 100 threads when applications open and close a large number of connections at a very high rate a lot of database resources will be spent on managing these connections instead of processing these queries and it degrades the database performance and proxy performs connection multiplexing it reduces the same database connection to serve multiple requests. for example whenever the connection is not actively executing during these times connections switch to another connection to perform an operation the connection multiplexing would work both for read write endpoint as well as read-only endpoints with this you can increase the scalability of your application without overloading the database resources and connection pooling would work both for rewrite endpoint as well as for read only endpoints for an aurora cluster. as you know in aurora you can have up to 15 reader nodes when connecting to the audience proxy RDS proxy read-only endpoint it automatically performs a load balancing between the reader nodes and during any role changes RDS proxy will check the replication lag of the old and new reader instance and draw the connection so that your application never sees the stale data.</p><p><strong>Availability:</strong></p><p>Application Connections are preserved, and the transactions are preserved during the failovers. When there is a database failover obvious proxy will preserve the connections which are not active and it will continue to accept the connection from an application even during the database failover process and will continue to queue up those connections as soon as the new instance comes up we’ll connect to the promoted instance and pause on any pending transaction that were queued up in RDS proxy now if you’re connecting directly to an or a cluster endpoint maybe the overall failover take can take less than 30 seconds in that 30 seconds most of the time goes into DNS propagation on top of that if you have downstream TTL or if you have application site connection pool with the long living connections your failover may experience or fail over time even become longer with audience proxy directly connect to an aurora instance it’s fully aware of the cluster topology so whenever there’s a change it’ll quickly detect the change because of that it provide up to 66 faster failovers.</p><p><strong>Improved Security:</strong></p><p>RDS Proxy integrates with AWS secrets manager. AWS secrets manager is an encrypted secret store so don’t notice so you don’t need to store any credentials in RDS proxy on top of that RDS proxy allows you to enforce the IAM authentication this IAM authentication is supported both for RDS and aurora with this you can enforce all users who are connected to RDS proxy must use an IAM authentication and avoid hard coding database credentials in our application code.</p><p>Firstly, I want to talk about how we can authorize and authenticate with RDS proxy you can continue to connect to audience proxy using the native way that is you establish a connection with your MYSQL or POSTGRES database using the same old username and password and the next option is you can show the secrets in AWS Secrets manager as I mentioned secrets manager is an encrypted secret store you can store the database secrets with the secrets manager you can easily rotate manage and reduce the database credentials you can just make an API called from your application to reduce the secrets and just start the connection another added layer of security control is that you can use the IAM authentication with an RDS proxy for authentication it is much more secure than connecting with the username and password once you get authenticated with RDS proxy with any of the above method that I mentioned then RDS proxy will get the credentials from the secrets manager and connect to the database.</p><p>Let’s see how IAM Authentication Works</p><p>first your application get the authentication token from an IAM and using that token your application make a connection to an audio proxy once that is validated in audience proxy as mentioned previously RDS proxy will retrieve the secrets from the sequence manager and it connects to the database by using this technique you can enforce a strong IAM authentication requirements for your database.</p><p>Let me show the Code: (Language: PYTHON) It is similar in all other languages as well</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jch6A7c5CGnuIJBXwjGmtg.png" /><figcaption>Example Code for RDS Proxy with IAM Authentication</figcaption></figure><p><strong>RDS Proxy Network and cross VPC Connectivity</strong></p><p>Amazon RDS recently introduced a new Feature in RDS proxy typically customers run their app servers and database servers in one VPC but it can be running on different subnets given that both app servers and database servers running in one VPC it is very easy to provide an access between each other by just allowing the security groups or the subnet type range let’s say you have some reporting application running in a different VPC in a same account and that application wants to access a database which is running in a different VPC usually you have an option to do a VPC Peering basically you have like a two VPC and those are appeared to each other which means it can communicate at the private VPC but when using VPC pairing basically you’re opening up two VPCs to each other even though you just want to access the database which is running on another VPC with an RDS proxy cross VPC connectivity you can just enable the cross VPC connectivity by creating an endpoint in your RDS proxy using this endpoint your application another VPC can communicate to the RDS proxy which is running on a different VPC.</p><p>With this, we were able to cover some basic features and use cases of Amazon RDS Proxy.</p><p>Thank You!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f5a6bd03bea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>