Are you over 18 and want to see adult content?
More Annotations
A complete backup of orffenspectacle.com
Are you over 18 and want to see adult content?
A complete backup of portofportland.com
Are you over 18 and want to see adult content?
A complete backup of thietbitrogiang.com.vn
Are you over 18 and want to see adult content?
A complete backup of endoscopiaterapeutica.com.br
Are you over 18 and want to see adult content?
A complete backup of seeunpark.wordpress.com
Are you over 18 and want to see adult content?
Favourite Annotations
A complete backup of samplebusinessresume.com
Are you over 18 and want to see adult content?
A complete backup of france-terre-asile.org
Are you over 18 and want to see adult content?
A complete backup of bangordailynews.com
Are you over 18 and want to see adult content?
A complete backup of oswegocounty.com
Are you over 18 and want to see adult content?
A complete backup of emergingthreats.net
Are you over 18 and want to see adult content?
A complete backup of microdream.co.uk
Are you over 18 and want to see adult content?
A complete backup of frenchbroadchocolates.com
Are you over 18 and want to see adult content?
Text
Udagedara
JALIYA'S BLOG: AZURE DURABLE FUNCTIONS AND EXTERNAL EVENTS In this post, let's see how we can make use of Azure Durable Functions with its External Event listening feature. This post assumes you have a basic understanding Durable Functions.. Let's consider the followingscenario.
JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS So here, if MyActvity throws an exception of type MyException, we will be retrying again in 10 seconds and maxNumberOfAttempts will be 3.One of the important things to note for the Handle delegate is, you need access exceptions' InnerException if you want to get the actualexception.
JALIYA'S BLOG: AZURE PIPELINES: PASSING VARIABLES BETWEEN Here, I have 2 Stages, Build and Deployment. Build stage has 2 jobs, ; In the FirstJob, I am creating a variable called myVariable.I am making it an output variable and setting its value to Hello World.; In the SecondJob, ; The SecondJob is depending on FirstJob because the variable needs to be created first.; Then I am declaring a variable called myJobVariable and mapping it with myVariable JALIYA'S BLOG: AZURE FUNCTIONS: CONSUMING CONFIGURATION So consider I have an Azure Function App with DI setup. Like 10 days back, Microsoft.Azure.Functions.Extensions version: 1.1.0 was released and with that, one of the new features that got available is Configuration source customization.Basically, that is, in the Startup class, now you can override the ConfigureAppConfiguration. JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the jointable.
AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installing the latest as of today which is 6.1.2) the project.In this application, I am going create a code-first sample database with three POCO entity types which are “Department”, “Hobby” and “Person”.I am modeling the entities and their relationships asfollows.
JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to JALIYA'S BLOG: APRIL 2021 The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
JALIYA'S BLOG: AZURE DURABLE FUNCTIONS AND EXTERNAL EVENTS In this post, let's see how we can make use of Azure Durable Functions with its External Event listening feature. This post assumes you have a basic understanding Durable Functions.. Let's consider the followingscenario.
JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS So here, if MyActvity throws an exception of type MyException, we will be retrying again in 10 seconds and maxNumberOfAttempts will be 3.One of the important things to note for the Handle delegate is, you need access exceptions' InnerException if you want to get the actualexception.
JALIYA'S BLOG: AZURE PIPELINES: PASSING VARIABLES BETWEEN Here, I have 2 Stages, Build and Deployment. Build stage has 2 jobs, ; In the FirstJob, I am creating a variable called myVariable.I am making it an output variable and setting its value to Hello World.; In the SecondJob, ; The SecondJob is depending on FirstJob because the variable needs to be created first.; Then I am declaring a variable called myJobVariable and mapping it with myVariable JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS Note: Sessions are available only in the Standard and Premium tiers of Service Bus. And once sessions are enabled for an entity (Queue/Subscription), that specific entity can only receive messages that have the SessionId set to a valid value. JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installing the latest as of today which is 6.1.2) the project.In this application, I am going create a code-first sample database with three POCO entity types which are “Department”, “Hobby” and “Person”.I am modeling the entities and their relationships asfollows.
JALIYA'S BLOG: AZURE DURABLE FUNCTIONS: CHANGE THE STORAGE During the Microsoft Build 2021 last week, there was an important announcement related to Azure Durable Functions.For all this time Azure Durable Functions was maintaining it's state in Azure Storage and we didn't have any control of that. These were mainly blobs,queues, tables.
JALIYA'S BLOG: EF CORE: USING HILO ALGORITHM TO GENERATE IDS This will return 1, and the category will be assigned the value of 1 and it has now blocked Ids from 1 to 10. If we add in another category in the same database context, EF won't run the above query again, it will increment the Id by 1 and when we have added 10 categories, EF will run the above query again to get the next value, which will be11.
JALIYA'S BLOG: AZURE PIPELINES: CREATE/UPDATE AZURE API Products; Since I have already created a product in the APIM, I can just enter the name of the Product. If you are creating the Product as part of the pipeline (using API Management - Create or update product task), then you need to select Product created by previous task. OpenAPI Specification JALIYA'S BLOG: EF CORE: OWNED ENTITY TYPES Note: I am using anotherContext here for retrieval, because EF Core will automatically fix-up navigation properties to any other entities that were previously loaded into the context instance. So even if you don't explicitly include the data for a navigation property, the property may still be populated if some or all of the related entities were previously loaded. JALIYA'S BLOG: C# 8.0: NOTNULL GENERIC CONSTRAINT A couple of months back I wrote a post about C# 8.0: Nullable Reference Types which is a feature coming with C# 8.0. A few days back Microsoft has released .NET Core 3.0 Preview 8. And from .NET Core 3.0 Preview 7 onwards, C# 8.0 is now considered feature complete. JALIYA'S BLOG: USING AN ICOMMAND FOR LISTVIEW ITEM CLICK When we are using MVVM, events triggered from the View should be bound to a ICommand in the ViewModel. In this post let’s see how we can bind an ItemClick event of a ListView to a implementation of a ICommand in the ViewModel. JALIYA'S BLOG: SQL SERVER REPORTING SERVICES (SSRS I had a requirement where I wanted to pass multi-valued parameters in a report querying a DB2 database. Couldn't do it myself and posted a question in SQL Server Reporting Services, Power View forum. This nice guy, Charlie Liao came in and solved my JALIYA'S BLOG: GETTING THE CURRENT USER'S SHAREPOINT GROUP Hi, Thanks for reply.checked the dataconnection it isperfect.bt it not retrieved the data.the same thing happenedin other forms also.i used some other forms and workflows.in some forms the dataconnection retrieved the value from sharepoint library.in some forms it hs notretrieved.idnt knw why it is notworked in some forms.Pls help me in this regard.i folow the same procd in allforms. JALIYA'S BLOG: APRIL 2021 The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. JALIYA'S BLOG: AZURE DURABLE FUNCTIONS AND EXTERNAL EVENTS Same as in the above step, we will have to either keep polling for status or the the external system will notify us when it's completed, so we can get a handle of the document generated. Now let's see how we can implement this using Azure Durable Functions and External Events. First I have below StarterFunction, which is basically the entrypoint.
JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: EF CORE: OWNED ENTITY TYPES EF Core: Owned Entity Types. In this post let's see what is Owned Entity Types in Entity Framework Core. This is a very nice feature when it comes to DDD. Owned Entities are entities that can be only appeared on navigation properties of other entity types. Basically, they can't exist without the Owner . JALIYA'S BLOG: AZURE PIPELINES: CREATE/UPDATE AZURE API Once this extension is installed, you should be able to see a bunch of tasks starting with API Management - *. From there what we need is API Management - Create or Update API task. We just need to add this task after the deployment of the API. API Management - Create or Update API. Then it's just a matter of configuring the task. JALIYA'S BLOG: C# 8.0: NOTNULL GENERIC CONSTRAINT A couple of months back I wrote a post about C# 8.0: Nullable Reference Types which is a feature coming with C# 8.0. A few days back Microsoft has released .NET Core 3.0 Preview 8. And from .NET Core 3.0 Preview 7 onwards, C# 8.0 is now considered feature complete. JALIYA'S BLOG: APRIL 2021 The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. JALIYA'S BLOG: AZURE DURABLE FUNCTIONS AND EXTERNAL EVENTS Same as in the above step, we will have to either keep polling for status or the the external system will notify us when it's completed, so we can get a handle of the document generated. Now let's see how we can implement this using Azure Durable Functions and External Events. First I have below StarterFunction, which is basically the entrypoint.
JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: EF CORE: OWNED ENTITY TYPES EF Core: Owned Entity Types. In this post let's see what is Owned Entity Types in Entity Framework Core. This is a very nice feature when it comes to DDD. Owned Entities are entities that can be only appeared on navigation properties of other entity types. Basically, they can't exist without the Owner . JALIYA'S BLOG: AZURE PIPELINES: CREATE/UPDATE AZURE API Once this extension is installed, you should be able to see a bunch of tasks starting with API Management - *. From there what we need is API Management - Create or Update API task. We just need to add this task after the deployment of the API. API Management - Create or Update API. Then it's just a matter of configuring the task. JALIYA'S BLOG: C# 8.0: NOTNULL GENERIC CONSTRAINT A couple of months back I wrote a post about C# 8.0: Nullable Reference Types which is a feature coming with C# 8.0. A few days back Microsoft has released .NET Core 3.0 Preview 8. And from .NET Core 3.0 Preview 7 onwards, C# 8.0 is now considered feature complete. JALIYA'S BLOG: EF CORE: OWNED ENTITY TYPES EF Core: Owned Entity Types. In this post let's see what is Owned Entity Types in Entity Framework Core. This is a very nice feature when it comes to DDD. Owned Entities are entities that can be only appeared on navigation properties of other entity types. Basically, they can't exist without the Owner . JALIYA'S BLOG: EF CORE 5.0: SAVECHANGES EVENTS AND Interceptors. Interceptors can be used for interception (as the name suggests of course), modification, and most importantly Interceptors allow SaveChanges to be suppressed unlike Events. It also provides async counterparts of methods so you can do async actions. Interceptors needs to implement ISaveChangesInterceptor interface. JALIYA'S BLOG: AZURE FUNCTIONS: CHANGE PLANTYPE FROM This is a quick post on how we can change the Plan Type of an Azure Function App from Consumption (Serverless) to a Premium Plan. If you have created an Azure Function App initially selecting Consumption (Serverless) as the plan type and then later if you want to change it to a Premium Plan, Azure Portal has no direct way to do it. Here youhave 2 options,
JALIYA'S BLOG: AZURE PIPELINES: PASSING VARIABLES BETWEEN Here, I have 2 Stages, Build and Deployment. Build stage has 2 jobs, ; In the FirstJob, I am creating a variable called myVariable.I am making it an output variable and setting its value to Hello World.; In the SecondJob, ; The SecondJob is depending on FirstJob because the variable needs to be created first.; Then I am declaring a variable called myJobVariable and mapping it with myVariable JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT ObjectStateManager in Entity Framework is responsible for tracking states and changes of an object. In this post let’s see how we can use ObjectStateManager to track object changes in following scenarios. Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installingthe
JALIYA'S BLOG: DOCKER DESKTOP FOR WINDOWS: KUBERNETES And from there onwards, it was easy to fix. According to issues/4316, I had to remove the folder named pki inside C:\ProgramData\DockerDesktop and restarted the docker. On the start, it will create the pki folder back again. And finally, it's all good. Kubernetes is running. But note, this might not be the reason for all the hangs at starting JALIYA'S BLOG: GETTING THE CURRENT USER'S SHAREPOINT GROUP Since this is going to to be a longer post, I think it's better to go as a step by step approach, so I will start from Step 01. Step 01. Select the Custom List and on Ribbon under List click Customize Form. Then the List will be opening in the Microsoft InfoPath Designer 2010. Step 02.
JALIYA'S BLOG: ASP.NET GRIDVIEW ROW EDIT MODE The editable fields of the row will change into edit mode and the "Edit" button will disappear. Instead of "Edit" button, three more buttons will come to the picture which will be "Update","Delete" and "Cancel". I hope you all got the target well, let's start achieving it. So basically we will have two modes and some custom controls. JALIYA'S BLOG: SQL SERVER REPORTING SERVICES (SSRS I had a requirement where I wanted to pass multi-valued parameters in a report querying a DB2 database. Couldn't do it myself and posted a question in SQL Server Reporting Services, Power View forum. This nice guy, Charlie Liao came in and solved my JALIYA'S BLOG: APRIL 2021 In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
JALIYA'S BLOG: EF CORE: USING HILO ALGORITHM TO GENERATE IDS In this post, let's see how we can use Hi/Lo algorithm as the key generation strategy in EF Core. This can be achieved using UseHiLo method. As always let's go by an example. Consider the below code. And MyDbContext is setup like this. . UseSqlServer ( "ConnectionString") .LogTo ( Console.
JALIYA'S BLOG: AZURE PIPELINES: PASSING VARIABLES BETWEEN Here, I have 2 Stages, Build and Deployment. Build stage has 2 jobs, ; In the FirstJob, I am creating a variable called myVariable.I am making it an output variable and setting its value to Hello World.; In the SecondJob, ; The SecondJob is depending on FirstJob because the variable needs to be created first.; Then I am declaring a variable called myJobVariable and mapping it with myVariable JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT ObjectStateManager in Entity Framework is responsible for tracking states and changes of an object. In this post let’s see how we can use ObjectStateManager to track object changes in following scenarios. Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installingthe
JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick JALIYA'S BLOG: APRIL 2021 In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
JALIYA'S BLOG: EF CORE: USING HILO ALGORITHM TO GENERATE IDS In this post, let's see how we can use Hi/Lo algorithm as the key generation strategy in EF Core. This can be achieved using UseHiLo method. As always let's go by an example. Consider the below code. And MyDbContext is setup like this. . UseSqlServer ( "ConnectionString") .LogTo ( Console.
JALIYA'S BLOG: AZURE PIPELINES: PASSING VARIABLES BETWEEN Here, I have 2 Stages, Build and Deployment. Build stage has 2 jobs, ; In the FirstJob, I am creating a variable called myVariable.I am making it an output variable and setting its value to Hello World.; In the SecondJob, ; The SecondJob is depending on FirstJob because the variable needs to be created first.; Then I am declaring a variable called myJobVariable and mapping it with myVariable JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT ObjectStateManager in Entity Framework is responsible for tracking states and changes of an object. In this post let’s see how we can use ObjectStateManager to track object changes in following scenarios. Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installingthe
JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick JALIYA'S BLOG: .NET 6 PREVIEW 4: INTRODUCING MINIMAL APIS In this post, let's see one of the nicest features coming in with ASP.NET Core in .NET 6.This feature is called Minimal APIs, the basic idea is being able to create a REST API with minimal code. JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick JALIYA'S BLOG: EARLY SUPPORT FOR .NET HOT RELOAD IS NOW .NET 6 Preview 3 is released just a couple of days back with some nice features.One of the nicest features that got released with this preview is the early support for .NET Hot Reload.Currently, it's only available for ASP.NET Core and Blazor Projects. JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: EF CORE 5.0: SAVECHANGES EVENTS AND Interceptors. Interceptors can be used for interception (as the name suggests of course), modification, and most importantly Interceptors allow SaveChanges to be suppressed unlike Events. It also provides async counterparts of methods so you can do async actions. Interceptors needs to implement ISaveChangesInterceptor interface. JALIYA'S BLOG: EF CORE: OWNED ENTITY TYPES EF Core: Owned Entity Types. In this post let's see what is Owned Entity Types in Entity Framework Core. This is a very nice feature when it comes to DDD. Owned Entities are entities that can be only appeared on navigation properties of other entity types. Basically, they can't exist without the Owner . JALIYA'S BLOG: AZURE PIPELINES: CREATE/UPDATE AZURE API Once this extension is installed, you should be able to see a bunch of tasks starting with API Management - *. From there what we need is API Management - Create or Update API task. We just need to add this task after the deployment of the API. API Management - Create or Update API. Then it's just a matter of configuring the task. JALIYA'S BLOG: POLLY: EXECUTING AN ACTION WITH RETRIES In this post, let's have a look at how we can execute any Actions with Retries using Polly.It's actually quite easy. Rather than explaining in words, a code sample would greatly explain itself. JALIYA'S BLOG: GETTING THE CURRENT USER'S SHAREPOINT GROUP Since this is going to to be a longer post, I think it's better to go as a step by step approach, so I will start from Step 01. Step 01. Select the Custom List and on Ribbon under List click Customize Form. Then the List will be opening in the Microsoft InfoPath Designer 2010. Step 02.
JALIYA'S BLOG: C# 8.0: NOTNULL GENERIC CONSTRAINT A couple of months back I wrote a post about C# 8.0: Nullable Reference Types which is a feature coming with C# 8.0. A few days back Microsoft has released .NET Core 3.0 Preview 8. And from .NET Core 3.0 Preview 7 onwards, C# 8.0 is now considered feature complete. JALIYA'S BLOG: APRIL 2021 In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: EF CORE: USING HILO ALGORITHM TO GENERATE IDS In this post, let's see how we can use Hi/Lo algorithm as the key generation strategy in EF Core. This can be achieved using UseHiLo method. As always let's go by an example. Consider the below code. And MyDbContext is setup like this. . UseSqlServer ( "ConnectionString") .LogTo ( Console.
JALIYA'S BLOG: AZURE PIPELINES: PASSING VARIABLES BETWEEN Here, I have 2 Stages, Build and Deployment. Build stage has 2 jobs, ; In the FirstJob, I am creating a variable called myVariable.I am making it an output variable and setting its value to Hello World.; In the SecondJob, ; The SecondJob is depending on FirstJob because the variable needs to be created first.; Then I am declaring a variable called myJobVariable and mapping it with myVariable JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT ObjectStateManager in Entity Framework is responsible for tracking states and changes of an object. In this post let’s see how we can use ObjectStateManager to track object changes in following scenarios. Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installingthe
JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick JALIYA'S BLOG: APRIL 2021 In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: EF CORE: USING HILO ALGORITHM TO GENERATE IDS In this post, let's see how we can use Hi/Lo algorithm as the key generation strategy in EF Core. This can be achieved using UseHiLo method. As always let's go by an example. Consider the below code. And MyDbContext is setup like this. . UseSqlServer ( "ConnectionString") .LogTo ( Console.
JALIYA'S BLOG: AZURE PIPELINES: PASSING VARIABLES BETWEEN Here, I have 2 Stages, Build and Deployment. Build stage has 2 jobs, ; In the FirstJob, I am creating a variable called myVariable.I am making it an output variable and setting its value to Hello World.; In the SecondJob, ; The SecondJob is depending on FirstJob because the variable needs to be created first.; Then I am declaring a variable called myJobVariable and mapping it with myVariable JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT ObjectStateManager in Entity Framework is responsible for tracking states and changes of an object. In this post let’s see how we can use ObjectStateManager to track object changes in following scenarios. Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installingthe
JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick JALIYA'S BLOG: .NET 6 PREVIEW 4: INTRODUCING MINIMAL APIS In this post, let's see one of the nicest features coming in with ASP.NET Core in .NET 6.This feature is called Minimal APIs, the basic idea is being able to create a REST API with minimal code. JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick JALIYA'S BLOG: EARLY SUPPORT FOR .NET HOT RELOAD IS NOW .NET 6 Preview 3 is released just a couple of days back with some nice features.One of the nicest features that got released with this preview is the early support for .NET Hot Reload.Currently, it's only available for ASP.NET Core and Blazor Projects. JALIYA'S BLOG: EF CORE 5.0: MANY TO MANY RELATIONSHIPS EF Core 5.0: Many to Many Relationships. One of the nicest features available in EF Core 5.0 is now you can define a many-to-many relationship without explicitly mapping the join table. With earlier EF Core versions, you didn't have the luxury of doing something like this, You needed to explicitly create the join table, something likebelow.
JALIYA'S BLOG: EF CORE 5.0: SAVECHANGES EVENTS AND Interceptors. Interceptors can be used for interception (as the name suggests of course), modification, and most importantly Interceptors allow SaveChanges to be suppressed unlike Events. It also provides async counterparts of methods so you can do async actions. Interceptors needs to implement ISaveChangesInterceptor interface. JALIYA'S BLOG: EF CORE: OWNED ENTITY TYPES EF Core: Owned Entity Types. In this post let's see what is Owned Entity Types in Entity Framework Core. This is a very nice feature when it comes to DDD. Owned Entities are entities that can be only appeared on navigation properties of other entity types. Basically, they can't exist without the Owner . JALIYA'S BLOG: AZURE PIPELINES: CREATE/UPDATE AZURE API Once this extension is installed, you should be able to see a bunch of tasks starting with API Management - *. From there what we need is API Management - Create or Update API task. We just need to add this task after the deployment of the API. API Management - Create or Update API. Then it's just a matter of configuring the task. JALIYA'S BLOG: POLLY: EXECUTING AN ACTION WITH RETRIES In this post, let's have a look at how we can execute any Actions with Retries using Polly.It's actually quite easy. Rather than explaining in words, a code sample would greatly explain itself. JALIYA'S BLOG: GETTING THE CURRENT USER'S SHAREPOINT GROUP Since this is going to to be a longer post, I think it's better to go as a step by step approach, so I will start from Step 01. Step 01. Select the Custom List and on Ribbon under List click Customize Form. Then the List will be opening in the Microsoft InfoPath Designer 2010. Step 02.
JALIYA'S BLOG: C# 8.0: NOTNULL GENERIC CONSTRAINT A couple of months back I wrote a post about C# 8.0: Nullable Reference Types which is a feature coming with C# 8.0. A few days back Microsoft has released .NET Core 3.0 Preview 8. And from .NET Core 3.0 Preview 7 onwards, C# 8.0 is now considered feature complete. JALIYA'S BLOG: APRIL 2021 In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT ObjectStateManager in Entity Framework is responsible for tracking states and changes of an object. In this post let’s see how we can use ObjectStateManager to track object changes in following scenarios. Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installingthe
JALIYA'S BLOG: USING AN ICOMMAND FOR LISTVIEW ITEM CLICKUWP LISTVIEWUWP LISTVIEW The easy way to do this by using Blend. Right click on the MainPage.xaml and click on “Open in Blend”. Opened in Blend. First open up the Objects and Timeline window, and drill up to ListView. Select the ListView and from the Assets window, select Behaviors and double click on EventTriggerBehavior. JALIYA'S BLOG: GETTING THE CURRENT USER'S SHAREPOINT GROUP Since this is going to to be a longer post, I think it's better to go as a step by step approach, so I will start from Step 01. Step 01. Select the Custom List and on Ribbon under List click Customize Form. Then the List will be opening in the Microsoft InfoPath Designer 2010. Step 02.
JALIYA'S BLOG: C# 8.0: NOTNULL GENERIC CONSTRAINT A couple of months back I wrote a post about C# 8.0: Nullable Reference Types which is a feature coming with C# 8.0. A few days back Microsoft has released .NET Core 3.0 Preview 8. And from .NET Core 3.0 Preview 7 onwards, C# 8.0 is now considered feature complete. JALIYA'S BLOG: APRIL 2021 In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: .NET CORE: TIERED COMPILATION A couple of days back during the .NET Conf, there were some major announcements along with the release of .NET Core 3.0.In this post, I am going to write about something which has been there for almost a year, wasn't available by default, but with .NET Core 3.0, it will be enabled by default.This feature is called Tiered Compilation. Before moving into Tiered Compilation, let's have a quick AZURE SERVICE BUS CLIENT LIBRARY FOR .NET: RECEIVERS VS The general recommendation is Processors should be the go-to tool for writing applications that receive messages from Service Bus entities.The Receivers are recommended for more complex scenarios in which the processor is not able to provide the fine-grained control that one can expect when using the Receiver directly. Azure Functions use Processors, so obviously, that's my go-to option. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER .NET, .NET Core, ASP.NET, ASP.NET Core, Visual Studio, JaliyaUdagedara
JALIYA'S BLOG: RETRYOPTIONS IN AZURE DURABLE FUNCTIONS The first retry will be in 10 seconds, the second retry will be in 20 seconds (after the first retry fail) and the final retry will be in 30 seconds (after the second retry fail). These are the different options available in RetryOptions that you can use to get the best retry experience. BackoffCoefficient: Gets or sets the backoff coefficient. JALIYA'S BLOG: USING OBJECTSTATEMANAGER FOR OBJECT ObjectStateManager in Entity Framework is responsible for tracking states and changes of an object. In this post let’s see how we can use ObjectStateManager to track object changes in following scenarios. Let’s jump into action by creating a console application and installing Entity Framework nuget package (I am installing installingthe
JALIYA'S BLOG: USING AN ICOMMAND FOR LISTVIEW ITEM CLICKUWP LISTVIEWUWP LISTVIEW The easy way to do this by using Blend. Right click on the MainPage.xaml and click on “Open in Blend”. Opened in Blend. First open up the Objects and Timeline window, and drill up to ListView. Select the ListView and from the Assets window, select Behaviors and double click on EventTriggerBehavior. JALIYA'S BLOG: GETTING THE CURRENT USER'S SHAREPOINT GROUP Since this is going to to be a longer post, I think it's better to go as a step by step approach, so I will start from Step 01. Step 01. Select the Custom List and on Ribbon under List click Customize Form. Then the List will be opening in the Microsoft InfoPath Designer 2010. Step 02.
JALIYA'S BLOG: C# 8.0: NOTNULL GENERIC CONSTRAINT A couple of months back I wrote a post about C# 8.0: Nullable Reference Types which is a feature coming with C# 8.0. A few days back Microsoft has released .NET Core 3.0 Preview 8. And from .NET Core 3.0 Preview 7 onwards, C# 8.0 is now considered feature complete. JALIYA'S BLOG: .NET 6 PREVIEW 4: INTRODUCING MINIMAL APIS In this post, let's see one of the nicest features coming in with ASP.NET Core in .NET 6.This feature is called Minimal APIs, the basic idea is being able to create a REST API with minimal code. JALIYA'S BLOG: AZURE SERVICE BUS: HANDLING FIFO USING SESSIONS In this post, let's see what Sessions are in Azure Service Bus. The primary use of Sessions (Groups) is to maintain FIFO when there are multiple receivers listening to the same Queue or Subscription. For the simplicity of the post, I will be focusing on Queues rather than Topics/Subscriptions, but the concept is the same. JALIYA'S BLOG: WPF: EXTERNAL LOGIN WITH IDENTITY SERVER WPF: External Login with Identity Server using Microsoft Edge WebView2 JALIYA'S BLOG: AZURE DURABLE FUNCTIONS AND EXTERNAL EVENTS Same as in the above step, we will have to either keep polling for status or the the external system will notify us when it's completed, so we can get a handle of the document generated. Now let's see how we can implement this using Azure Durable Functions and External Events. First I have below StarterFunction, which is basically the entrypoint.
JALIYA'S BLOG: EF CORE: USING HILO ALGORITHM TO GENERATE IDS This will return 1, and the category will be assigned the value of 1 and it has now blocked Ids from 1 to 10. If we add in another category in the same database context, EF won't run the above query again, it will increment the Id by 1 and when we have added 10 categories, EF will run the above query again to get the next value, which will be11.
JALIYA'S BLOG: CALLING WCF SERVICE FROM A STORED PROCEDURE So what we can do is write a Stored Procedure with the use of SQL CLR which will call and consume from the WCF Service. Then we can write a T-SQL Stored Procedure to call the SQL CLR Stored Procedure. Different SQL Server versions uses different CLR versions. SQL Server 2012 uses version 4.0 of the CLR although previous versions of SQL Server JALIYA'S BLOG: ASP.NET GRIDVIEW ROW EDIT MODE The editable fields of the row will change into edit mode and the "Edit" button will disappear. Instead of "Edit" button, three more buttons will come to the picture which will be "Update","Delete" and "Cancel". I hope you all got the target well, let's start achieving it. So basically we will have two modes and some custom controls. JALIYA'S BLOG: SQL SERVER REPORTING SERVICES (SSRS I had a requirement where I wanted to pass multi-valued parameters in a report querying a DB2 database. Couldn't do it myself and posted a question in SQL Server Reporting Services, Power View forum. This nice guy, Charlie Liao came in and solved my JALIYA'S BLOG: C# 8.0: NULLABLE REFERENCE TYPES So starting with C# 8.0, all the reference type variables are not nullable and if the compiler sees a code trying to dereference a non-nullable reference type, it will issue a warning. But as of now, you are opted-out for this feature by default. You can opt-in to this feature (which is known as nullable contexts) using the following twoJALIYA'S BLOG: 2013
Getting Caller Information using Caller Info attributes is initially introduced with .NET Framework 4.5. It can be real handy if you want to write a module for tracing, debugging etc.JALIYA'S BLOG
PAGES
* Home
* Sessions
* TNWiki
* Featured
* Contact
SUNDAY, MARCH 22, 2020 MAINTAIN ENTITY FRAMEWORK CORE DBCONTEXT IN A SEPARATE PROJECT Usually, when I have an application that has an API and a Database managed with EF, I really don't like to have the Application DbContext and all the Migrations inside the API project. It's actually very easy to split it out, this is a quick post on how we can maintain Entity Framework Core DbContext in a separate project. I have created a Solution WEBAPPLICATION1 which has 2 projects, one is ASP.NET Core Web API and the other one just a .NET Core Class Library where I am maintaining Database specific things.Solution
For WEBAPPLICATION1.DATA project, I have installed MICROSOFT.ENTITYFRAMEWORKCORE.SQLSERVER package and my WEBAPPLICATION1.DATA.CSPROJ looks like this.{
public class Employee{
public int Id { get; set; } public string FirstName { get; set; } public string LastName { get; set; }}
public class ApplicationDbContext : DbContext{
public ApplicationDbContext(DbContextOptions options) : base(options){
}
public DbSet}
}
Then inside my WEBAPPLICATION1.API project, I have referenced WEBAPPLICATION1.DATA project and installed MICROSOFT.ENTITYFRAMEWORKCORE.TOOLS package there. This is very much required. This is my WEBAPPLICATION1.API.CSPROJ looks like.{
services.AddControllers(); services.AddDbContext{
options.UseSqlServer(Configuration.GetConnectionString("ApplicationDbContext"));});
}
So basically that's it. Using the PACKAGE MANAGER CONSOLE in Visual Studio, I can run ADD-MIGRATION command targetting WEBAPPLICATION.DATAproject.
Package Manager Console Or alternatively using DOTNET EF global tool (you need to install the tool first). The parameters are self-explanatory. dotnet ef migrations add Initial --project .\WebApplication1.Data\WebApplication1.Data.csproj --startup-project .\WebApplication1.Api\WebApplication1.Api.csproj And it will add all the Migrations inside WEBAPPLICATION.DATA project which is what I wanted.Migrations
To apply the migrations, again using the PACKAGE MANAGER CONSOLE in Visual Studio, I can run UPDATE-DATABASE command targetting WEBAPPLICATION.DATA. Or using the CLI, dotnet ef database update --project .\WebApplication1.Data\WebApplication1.Data.csproj --startup-project .\WebApplication1.Api\WebApplication1.Api.csprojThat was easy.
Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 12:59 AM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
WEDNESDAY, MARCH 18, 2020 DOTNET EF COMMAND DOESN'T WORK INSIDE A DOCKER CONTAINER I was facing this issue where I needed to run DOTNET EF command inside a docker container and it's not recognizing the command. Basically, my Dockerfile looked something like. FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build RUN dotnet tool install -g dotnet-ef --version 3.1.1 RUN export PATH="$PATH:/root/.dotnet/tools"RUN dotnet ef
I was installing DOTNET-EF command, and I was setting the path. But still, I was getting this error, Could not execute because the specified command or file was not found. Possible reasons for this include: * You misspelled a built-in dotnet command. * You intended to execute a .NET Core program, but dotnet-ef does not exist. * You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH. I have been trying different things for a couple of hours, finally, thanks to Petr Onderka with his brilliant answer managed to solve the issue. The reason is for it's to not work is the environment variables set by EXPORT don't survive across directives. What we need to do is to use the ENV directive instead.And this worked.
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS build RUN dotnet tool install -g dotnet-ef --version 3.1.1 ENV PATH $PATH:/root/.dotnet/tools RUN dotnet ef --version Thanks Petr Onderka again. I hope this saves someone's time.Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 2:21 PM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
WEDNESDAY, MARCH 4, 2020 VISUAL C# TECHNICAL GURU - JANUARY 2020 Another month as a judge in Microsoft TechNet Guru Awards under Visual C# category. The TechNet Guru Awards celebrate the technical articles on Microsoft TechNet. Post in Official Blog, https://techcommunity.microsoft.com/t5/azure-developer-community-blog/technet-guru-winners-january-2020/ba-p/1207718 Visual C# Technical Guru - January 2020Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 6:16 PM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
SATURDAY, FEBRUARY 29, 2020 ASP.NET CORE APPLICATION READING CONFIGURATION FROM AZURE APPCONFIGURATION
In this post let's see how we can setup configuration settings for ASP.NET Core Application to read from AZURE APP CONFIGURATION. Azure App Configuration is a managed service by Azure that provides a way to centrally manage application settings and feature flags. Nowadays a single application consists of multiple components running in different places, so the idea behind Azure App Configurationis
having a single place to manage all your configuration settings. It's always better to go by demonstration. Let's start by creating an Azure App Configuration service in Azure.App Configuration
I am clicking on create. App Configuration Setup We just need to enter the basic information and I am completing the creation with the above settings. Once that is created, we can create the settings by navigating into SETTINGS -> CONFIGURATION EXPLORER. Configuration explorer Configuration settings here are basically a Key-Value pair. Before adding any values, let's create an ASP.NET Core Application and configure it to read settings from here. For the demo purpose, I will just create an API application named AZUREAPPCONFIGURATIONDEMO and Iam adding the NuGet
package Microsoft.Azure.AppConfiguration.AspNetCorewhich
will enable adding Microsoft Azure App Configuration as a configuration source in our application. Now I am updating the Program.cs to configure the Azure App Configuration we created above to be used in our application. public class Program{
public static void Main(string args){
CreateHostBuilder(args).Build().Run();}
public static IHostBuilder CreateHostBuilder(string args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder =>{
webBuilder
.ConfigureAppConfiguration((hostingContext, config) =>{
var settings = config.Build(); config.AddAzureAppConfiguration(settings);})
.UseStartup});
}
Here, under the CONFIGUREAPPCONFIGURATION, we can add the AzureApp Configuration with a target connection string. You can find the connection string under Settings -> Access Keys inside the Azure AppConfiguration.
Access Keys
Now I am adding the secret named CONNECTIONSTRINGS:APPCONFIG to Secret Manager. We can do this by either running DOTNET USER-SECRETS SET command or if you are using Visual Studio by right-clicking on the project and MANAGE USER SECRETS. dotnet user-secrets set ConnectionStrings:AppConfig "{
private IConfiguration Configuration { get; } public SettingsController(IConfiguration configuration){
Configuration = configuration;}
public IActionResult GetValue(){
string value = Configuration;return Ok(value);
}
}
Now let's create the key: "AZUREAPPCONFIGURATIONDEMO:TESTKEY" by going back to SETTINGS -> CONFIGURATION EXPLORER in our Azure AppConfiguration.
Add Key
I am leaving Label and Content Type empty for now and I am clickingon Apply.
Now we are all set. Let's run the application.Result
And here it is. Hope this helps.Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 3:13 PM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
WEDNESDAY, JANUARY 29, 2020 VISUAL C# TECHNICAL GURU - DECEMBER 2019 Another month as a judge in Microsoft TechNet Guru Awards under Visual C# category. The TechNet Guru Awards celebrate the technical articles on Microsoft TechNet. Post in Official Blog, https://techcommunity.microsoft.com/t5/azure-developer-community-blog/technet-guru-winners-december-2019/ba-p/1138044 Visual C# Technical Guru - December 2019Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 11:12 PM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
MONDAY, JANUARY 27, 2020 SETTING UP AZURE DEVOPS PIPELINE TO CI/CD DOCKER IMAGE INTO AZUREKUBERNETES SERVICE
In this post, let's see how we can set up an Azure DevOps pipeline to Contonius Integrate and Deploy a Docker Image containing a simple ASP.NET Core Web Application to Azure Kubernetes Service (AKS). This post is another post of a series of blog posts, * Deploying an ASP.NET Core Application On a Local KubernetesCluster
* Pushing Local Docker Image to an Azure Container Registry * Deploying an ASP.NET Core Application On Azure Kubernetes Service and if you are landed directly on this post, please consider reading all of them to get the context. It's basically, I have created a docker image with a simple ASP.NET Core Web Application. In the first post, I have deployed that image into a local K8s cluster. Then in the second post, I have pushed the docker image to ACR. In the third post, I have deployed the same image to AKS and the image was picked up from ACR, and everything was manual. And this post, we are going to make it automated, that is when we do a change to our code, we are going to build and push the image to ACR, and then it will get deployed to AKS. So I have my ASP.NET Core Web Application pushed to Azure DevOps.Solution
Now I am enabling MULTI-STAGE PIPELINES from the PREVIEW FEATURES.Preview features
Multi-stage pipelines And let's start creating the pipeline. Click on the CREATE PIPELINE.Create Pipeline
Now, where is our code?Where is your code
I am selecting AZURE REPOS GIT as that's where my source code is in. You can choose your git provider based on wherever you have put yoursource in.
And it will display the list of repositories and I am selecting myrepo.
Select a repository
Next, we need to configure the pipeline. Configure your pipeline Here different templates are displayed, what we are going to be using is DEPLOY TO AZURE KUBERNETES SERVICE and this was enabled by selecting MULTI-STAGING PIPELINES under PREVIEW FEATURES. And now, if you have multiple Azure subscriptions, a side panel will be opened to select the subscription, and you can select the subscription which you have used to create your ACR and AKS. After that stage, now we need to select the AKS cluster and the ACR. Select the cluster/container registry and the image So here the UI is self-explanatory, I am selecting the existing AKS cluster and the container registry. About the NAMESPACE, all Kubernetes resources, such as pods and Deployments, are logically grouped into a namespace. These groupings provide a way to logically divide an AKS cluster and restrict access to create, view, or manage resources. So here for the demo purpose, I have selected existing and selected DEFAULT, and that is the namespace where pods and deployments are created when none is provided. For the IMAGE NAME, I am giving KUBE-WEATHER. Service Port is 80. And I am not enabling Review App flow for Pull Requests to keep things simple and I am clicking on VALIDATE AND CONFIGURE. And Azure DevOps will create an AZURE-PIPELINES.YML for us.azure-pipelines.yml
AZURE-PIPELINES.YML
# Deploy to Azure Kubernetes Service # Build and push image to Azure Container Registry; Deploy to Azure Kubernetes Service # https://docs.microsoft.com/azure/devops/pipelines/languages/dockertrigger:
- master
resources:
- repo: self
variables:
# Container registry service connection established during pipeline creation dockerRegistryServiceConnection: 'dfaa78f5-f305-4029-8682-41382d284928' imageRepository: 'kube-weather' containerRegistry: 'playground01.azurecr.io' dockerfilePath: '**/Dockerfile' tag: '$(Build.BuildId)' imagePullSecret: 'playground0116314274-auth' # Agent VM image name vmImageName: 'ubuntu-latest'stages:
- stage: Build
displayName: Build stagejobs:
- job: Build
displayName: Build
pool:
vmImage: $(vmImageName)steps:
- task: Docker@2
displayName: Build and push an image to container registryinputs:
command: buildAndPush repository: $(imageRepository) dockerfile: $(dockerfilePath) containerRegistry: $(dockerRegistryServiceConnection)tags: |
$(tag)
- upload: manifests artifact: manifests- stage: Deploy
displayName: Deploy stagedependsOn: Build
jobs:
- deployment: Deploy displayName: Deploypool:
vmImage: $(vmImageName) environment: 'KubeWeather.default'strategy:
runOnce:
deploy:
steps:
- task: KubernetesManifest@0 displayName: Create imagePullSecretinputs:
action: createSecret secretName: $(imagePullSecret) dockerRegistryEndpoint: $(dockerRegistryServiceConnection) - task: KubernetesManifest@0 displayName: Deploy to Kubernetes clusterinputs:
action: deploy
manifests: |
$(Pipeline.Workspace)/manifests/deployment.yml $(Pipeline.Workspace)/manifests/service.yml imagePullSecrets: |$(imagePullSecret)
containers: |
$(containerRegistry)/$(imageRepository):$(tag) If you read this file carefully, most of them are self-explanatory. But let's go through. * First, we have a trigger for the master branch. That is when we merge a PR to master branch or on a direct push to master branch, this pipeline will get triggered. * And then RESOURCES.REPO means the repository that azure-pipelines.yml file is in, In this case, it's our repo, we really don't need this line. * Then we have some variables defined based on the information we have selected on the UI. * And we are doing the build and deploy using a VM and that VM will be running on the latest ubuntu. * Then we have stages section, where we have 2 sections, one for BUILD and the other for DEPLOY.* Build
* Under here our source in the master branch will get built as a docker image and will get pushed to our container registry as KUBE-WEATHER and will get tagged with BuildId.* Deploy
* Under here, we are pulling up the image from our ACR and spinning up a container in our target cluster to an environment named KUBEWEATHER.DEFAULT (this is the environment name and the namespace). And the deployment is happening using the RunOnce deployment strategy which is simplest. You can read more about the key concepts and components that are used in Azure Pipelines from here: Key concepts for new Azure Pipelinesusers
So now, let's click on SAVE AND RUN.Save and run
And it's going to add 3 files to our repo, AZURE-PIPELINES.YML, we already have and it's going to add 2 new files (DEPLOYMENT.YML, SERVICE.YML) to a folder named manifests. In my last post: Deploying an ASP.NET Core Application On Azure Kubernetes Service,
I have added these files manually (if you have read this post). In the solution, I have pushed I don't have these files checked in. Let's see what Azure DevOps is going to create for us. I am hitting on SAVE ANDRUN.
After some time, Build and Deploy is succeeded. Before examining the Build/Deploy, let's do a pull from our repo's master branch and investigate the files (DEPLOYMENT.YML and SERVICE.YML) Azure DevOps has added.Folder View
DEPLOYMENT.YML
apiVersion : apps/v1beta1kind: Deployment
metadata:
name: kube-weather
spec:
replicas: 1
template:
metadata:
labels:
app: kube-weather
spec:
containers:
- name: kube-weather image: playground01.azurecr.io/kube-weatherports:
- containerPort: 80SERVICE.YML
apiVersion: v1
kind: Service
metadata:
name: kube-weather
spec:
type: LoadBalancer
ports:
- port: 80
selector:
app: kube-weather
Those basically are the files that in the previous post we have manually added with some information missing but we get theidea.
Now let's investigate the Build/Deploy, for that let's go to Pipelines-> Environments,
Environments
And click on the environment name.Namespaces
And you can see our namespace. Remember: we used the namespace nameDEFAULT.
Workloads
And you can see the deployments. Let's click on the Services tab.Services
And there we have the service information. You can click on it and investigate what is inside. But here I am after the External IP. And I am opening the http://13.83.56.17/weatherforecast and it'srunning.
Running
Hope this helps.
Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 9:42 AM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
SATURDAY, JANUARY 25, 2020 DEPLOYING AN ASP.NET CORE APPLICATION ON AZURE KUBERNETES SERVICE In my last 2 posts, I wrote about all the groundwork required forthis post.
* Deploying an ASP.NET Core Application On a Local KubernetesCluster
* Pushing Local Docker Image to an Azure Container Registry So in the first post, I have created a docker image with a simple ASP.NET Core Web API application and showed how we can deploy it into a local K8s cluster. In the second post, I wrote about how we can deploy a docker image to an Azure Container Registry (ACR). So in this post, let's see how we can deploy a docker image with an ASP.NET Core Application on Azure Kubernetes Service (AKS). Here I will be using the docker image (KUBE-WEATHER:DEV) which we have published to our ACR in this post.
And in this post, let's see how we can do below.* Setup an AKS
* Grant the AKS Service Principle access to our ACR * Deploy the service1. SETUP AN AKS
For this, let's create a Kubernetes Service in Azure.Kubernetes Service
I am clicking on Create.Basics
Here I have entered some basic information. And you can select a node pool with basic Node size. And here I have Node count set to 3, even 1 should be enough and I am clicking on NEXT: SCALE.Scale
Here default settings should be enough and going to NEXT:AUTHENTICATION.
Authentication
THIS STEP IS IMPORTANT. Here we need to create a new Service Principal for our cluster. But unfortunately for some reason, we weren't provided an option to give a principal name, and we are planning on using the name in a later step. Because of that, I am creating a Service Principal using Azure CLI as below. PS C:\Users\Jaliya> az ad sp create-for-rbac --skip-assignment --name SP-PlayGround01-Cluster Changing "SP-PlayGround01-Cluster" to a valid URI of "http://SP-PlayGround01-Cluster", which is the required format used for service principal names{
"appId": "4b7ff1c6-a2ce-4b49-a197-dedabe04717b", "displayName": "SP-PlayGround01-Cluster", "name": "http://SP-PlayGround01-Cluster", "password": "e22efd43-60dc-4dca-8f2d-e2fced07780a", "tenant": "1f4a5f26-b0bc-402c-9347-e0f7d16c098f"}
And I am using the APPID and PASSWORD information which were outputted and selecting USE EXISTING in above to configure the service principal and I am going to NEXT: NETWORKING.Networking
For networking, defaults are fine and going to NEXT: MONITORING.Monitoring
And for Monitoring, I have created a Log Analytics workspace with a proper name and going to NEXT: TAGS.Tags
I don't have any tags, I am leaving it empty and going to REVIEW + CREATE. In the review step, it will do some validations and once passed, I have clicked on CREATE. And it will take a couple of minutesto set up the AKS.
And it's created.
playground01-kubernetes-cluster 2. GRANT THE SERVICE PRINCIPLE WE CREATED ABOVE ACCESS TO OUR ACR For this, let's navigate to our ACR PLAYGROUND01 which we have created in my previous blog post: Pushing Local Docker Image to an AzureContainer Registry
ACR
From there, click on ACCESS CONTROL (IAM) and then ADD A ROLE ASSIGNMENT. And from the next pane, select Role ACRPULL. And from Assign access to, keep the default which is AZURE AD USER, GROUP AND SERVICE PRINCIPAL. And from the Select, search for SP-PLAYGROUND01-CLUSTER and Save. For some reason, The Role dropdown doesn't work, so I am doing the above using Azure CLI. If you are also unable to do, you can use theCLI.
az role assignment create --assignee $SERVICE_PRINCIPAL_ID --scope $ACR_REGISTRY_ID --role acrpull $SERVICE_PRINCIPAL_ID, we already know, it's the APPID that was outputted when we created the service principal from Azure CLI. We can get the $ACR_REGISTRY_ID from running below command. az acr show --name $ACR_NAME --query id --output tsv Here $ACR_NAME is our ACR name, in my case, it's PLAYGROUND01. So I ran the command and I have verified it's created by going to VIEWROLE ASSIGNMENTS.
Now we are almost at the final step. 3. DEPLOY THE SERVICE From Azure CLI, I am running the following command to configure KUBECTL to connect to my K8s cluster. PS C:\Users\Jaliya> az aks get-credentials --resource-group playground01-kubernetes-service --name playground01-kubernetes-cluster Merged "playground01-kubernetes-cluster" as current context in C:\Users\Jaliya\.kube\config Now I am creating 2 yml configuration files (the same way I have created for local deployments in one of my previous posts: Deploying an ASP.NET Core Application On a Local Kubernetes Cluster).
I am not going to explain these in detail, please do read the above blog post for more information.DEPLOYMENT.YML
apiVersion: apps/v1kind: Deployment
metadata:
name: kube-weather-deploymentspec:
selector:
matchLabels:
app: kube-weather-podtemplate:
metadata:
labels:
app: kube-weather-podspec:
containers:
- name: kube-weather-container image: playground01.azurecr.io/kube-weather:devresources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80 The only difference in this file from my previous blog post sample is the image. Instead of picking up a local image, I am picking up theimage from our ACR.
SERVICE.YML
apiVersion: v1
kind: Service
metadata:
name: kube-weather-servicespec:
selector:
app: kube-weather-podports:
- port: 9095
targetPort: 80
type: LoadBalancer
The next step is to deploy. I have navigated to my desktop from CLI as that's where I have my configuration files. PS C:\Users\Jaliya\Desktop> kubectl apply -f .\deployment.yml deployment.apps/kube-weather-deployment created PS C:\Users\Jaliya\Desktop> kubectl apply -f .\service.yml service/kube-weather-service created PS C:\Users\Jaliya\Desktop> kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kube-weather-service LoadBalancer 10.0.67.235it is running.
Running
Hope this helps.
Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 2:54 PM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
THURSDAY, JANUARY 23, 2020 PUSHING LOCAL DOCKER IMAGE TO AN AZURE CONTAINER REGISTRY In this post, let's see how we can push a local docker image to an Azure Container Registry. For this post, I am using a very simple local docker image KUBE-WEATHER:DEV which I have created in my previous post: Deploying an ASP.NET Core Application On a LocalKubernetes Cluster
.
First, let's create an Azure Container Registry (ACR). It's actually pretty straight forward, don't think any explanations are necessary.Create an ACR
Then we need to push our image. For that, we will be using Azure CLI and make sure you have Azure CLIinstalled.
Now then open up a PowerShell window and run the below command tologin to Azure.
PS C:\Users\Jaliya> az login It will open up a browser and upon sign in, it will list down all the subscriptions (with it's information such as id etc.) you have access to. If you have multiple, run the below command to find out what subscription is selected as default by Azure CLI. PS C:\Users\Jaliya> az account show If it's not the subscription where you have created the ACR in, you can change the subscription by running the below command. PS C:\Users\Jaliya> az account set --subscription {id of the target subscription} Once the correct subscription is selected, let's sign in to our ACR. For that, run the following command. PS C:\Users\Jaliya> az acr login --name playground01Login Succeeded
Here the name is whatever the name you have given for your ACR. In my case, it was PLAYGROUND01 and I am logged in. Now run the below command to create a new image of KUBE-WEATHER:DEVimage.
PS C:\Users\Jaliya> docker tag kube-weather:dev playground01.azurecr.io/kube-weather:dev Here the target image should be in the following format : YOURACRLOGINSERVER:TARGETIMAGENAME:TAG.Login server
And now if you run DOCKER IMAGES command, you will see a new image is created referencing the original image and have the same image id. PS C:\Users\Jaliya> docker images REPOSITORY TAG IMAGE ID CREATED SIZE kube-weather dev d9cd7bec80e7 2 days ago 208MB playground01.azurecr.io/kube-weather dev d9cd7bec80e7 2 days ago 208MB Now we are almost there. The final step is to push the new image to our ACR. For that, let's run the below command. And it will take some time based on the size and will display you a progressive output. PS C:\Users\Jaliya> docker push playground01.azurecr.io/kube-weather:dev The push refers to repository 5f3ec39d44c0: Pushed b4ab3aec213b: Pushed 05682a6a4056: Pushed fcd021389694: Pushed 2c52aed6692d: Pushed c51868eee26f: Pushed 556c5fb0d91b: Pushed dev: digest: sha256:b2725ccbc89e9684e406d5a20213562f9908e93f402570821a98285bc8d9a81d size: 1790 All good. Now if you have a look at our ACR, our KUBE-WEATHER imageshould be there.
ACR-Repositories
And it is.
Hope this helps.
Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 12:53 PM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
WEDNESDAY, JANUARY 22, 2020 DEPLOYING AN ASP.NET CORE APPLICATION ON A LOCAL KUBERNETES CLUSTER In this post, let's see how we can deploy an ASP.NET Core application on a local Kubernetes (K8s) cluster. So the first is to set up a local K8s cluster and luckily DOCKERDESKTOP includes
a standalone K8s server and client, as well as Docker CLI integration. The K8s server runs locally within your Docker instance, is not configurable, and is a single-node cluster. So I have Docker Desktop installed in my Windows 10 machine and enabled Kubernetes. Once enabled, make sure you can see "Kubernetes is running" in the lower-left corner of Docker Desktop and the DOCKER-DESKTOP is selected as the context. Enable K8s and is runningContext
The next step is to create a Docker Image of an ASP.NET Core Application. Here I have created an ASP.NET Core Web API application with the default template and with Docker enabled.Solution
And I have updated the default Dockerfile as follows.DOCKERFILE
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-buster-slim AS baseWORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-buster AS buildWORKDIR /src
COPY
RUN dotnet restore "./Kube.Weather.Api.csproj"COPY . .
RUN dotnet build "Kube.Weather.Api.csproj" -c Release -o /app/build FROM build AS publish RUN dotnet publish "Kube.Weather.Api.csproj" -c Release -o /app/publish FROM base AS finalWORKDIR /app
COPY --from=publish /app/publish .ENTRYPOINT
And then I have created a Docker image by running the followingcommand.
docker build -t kube-weather:dev . And the image is created. And this is the image that we are going todeploy into K8s.
PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> docker images REPOSITORY TAG IMAGE ID CREATED SIZE kube-weather dev d9cd7bec80e7 22 seconds ago 208MB Actually, before deploying, it's worth to check whether the image is working fine locally. I can just spin up a new container out of the image by running the below command. docker run -it --rm -p 9090:80 kube-weather:dev Here I am running the image KUBE-WEATHER:DEV in interactive mode and binding the port 80 of the container to 9090, so I can access the application through localhost:9090. And yes, it's working. Running inside Docker The next step is to deploy the image to our local K8s cluster. Let's start by adding a .yml configuration file named deployment.yml. (you can name it with whatever name you like). To scaffold the content of this file, you can use the KUBERNETES extension in VS CODE. And you can basically type DE... and it will scaffold the file for you.deployment.yml
And I have updated the scaffolded content as below.DEPLOYMENT.YML
apiVersion: apps/v1kind: Deployment
metadata:
name: kube-weather-deploymentspec:
selector:
matchLabels:
app: kube-weather-podtemplate:
metadata:
labels:
app: kube-weather-podspec:
containers:
- name: kube-weather-container image: kube-weather:devresources:
limits:
memory: "128Mi"
cpu: "500m"
ports:
- containerPort: 80So here,
* A deployment named KUBE-WEATHER-DEPLOYMENT is created. * The selector field defines how the Deployment finds which Pods to manage. In this case, we have simply selected a label that is defined in the Pod template (APP: KUBE-WEATHER-POD) * The template field contains the following sub-fields: * The Pods are labeled APP: KUBE-WEATHER-POD the labels field. * The Pod template’s specification, or .TEMPLATE.SPEC field, indicates that the Pods run one container, KUBE-WEATHER-CONTAINER, which runs the KUBE-WEATHER:DEV, my local Docker image. * The container limits memory of 128MI (Mebibyte = 1 MiB => 1.04858 MB) and CPU of 500M (The unit suffix m-milliCPU stands for "thousandthof a core")
* And finally, we are asking the port 80 to be exposed Next, let's apply this deployment configuration to our local K8s cluster. Before that let's have a quick look at the status of nodes, deployments, and pods in our K8s cluster. PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> kubectl get nodes NAME STATUS ROLES AGE VERSION docker-desktop Ready master 23h v1.14.8 PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> kubectl get deployment No resources found. PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> kubectl get pods No resources found. So I have a single node in ready status and there are no deployments and thus no pods so far. Let's apply the deployment configuration by running the followingcommand.
PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> kubectl apply -f .\deployment.yml deployment.apps/kube-weather-deployment created And the deployment is created. Now if I checked the deployment and pods, I can see my deployment and a pod is there running. PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> kubectl get deployment NAME READY UP-TO-DATE AVAILABLE AGE kube-weather-deployment 1/1 1 1 86s PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> kubectl get pods NAME READY STATUS RESTARTS AGE kube-weather-deployment-d96787866-fhrdt 1/1 Running 0 94s Still, the application running inside the pod is not accessible to outside. For that, we need to create a service which is an abstract way to expose an application running on a set of Pods as a network service. For that, let's create another .yml configuration file named service.yml. (again you can name it with whatever the name you like). And again you can use KUBERNETES extension in VS Code and you can type SE... and it will scaffold the file for you.service.yml
I have updated the scaffolded content as below.SERVICE.YML
apiVersion: v1
kind: Service
metadata:
name: kube-weather-servicespec:
selector:
app: kube-weather-podports:
- port: 9095
targetPort: 80
type: LoadBalancer
So here,
* This specification creates a new Service object named “KUBE-WEATHER-SERVICE”. * Then we are mentioning, the service targets port 80 on any Pod having the label APP=KUBE-WEATHER-POD. * Port 9095 is where the service receives a request. Next before applying this service, let's have a look at do we have any existing services. PS C:\Users\Jaliya\Desktop\Kube.Weather\Kube.Weather.Api> kubectl get services NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1Running inside K8s
So that's it, we have an ASP.NET Core Web API application running inside a local K8s cluster. Hope this helps. Feedback is alwayswelcome.
Happy Coding.
Regards,
Jaliya
Posted by Jaliya Udagedara at 1:37 PM0 comments
Email This
BlogThis!
Share
to Twitter
Share
to Facebook
Share
to Pinterest
Reactions:
Older Posts
Home
Subscribe to: Posts (Atom) DEVELOPER TECHNOLOGIESWIKI NINJA
FOLLOW ME ON TWITTERABOUT ME
* Jaliya Udagedara
View my complete profileBLOG ARCHIVE
* ▼ 2020 (11)
* ▼ March (3)
* Maintain Entity Framework Core DbContext in a Sepa... * dotnet ef Command Doesn't Work inside a Docker Con... * Visual C# Technical Guru - January 2020 * ► February (1) * ► January (7)* ► 2019 (37)
* ► December (3) * ► November (4) * ► October (4)* ► September
(2)
* ► August (2)
* ► July (4)
* ► June (3)
* ► May (2)
* ► April (5)
* ► March (2)
* ► February (4) * ► January (2)* ► 2018 (51)
* ► December (4) * ► November (5) * ► October (3)* ► September
(5)
* ► August (3)
* ► July (3)
* ► June (5)
* ► May (5)
* ► April (6)
* ► March (4)
* ► February (1) * ► January (7)* ► 2017 (37)
* ► December (2) * ► November (5) * ► October (2)* ► September
(2)
* ► August (3)
* ► July (2)
* ► June (4)
* ► May (5)
* ► April (2)
* ► March (3)
* ► February (3) * ► January (4)* ► 2016 (45)
* ► December (3) * ► November (2) * ► October (2)* ► September
(6)
* ► August (3)
* ► July (4)
* ► June (6)
* ► May (4)
* ► April (2)
* ► March (2)
* ► February (6) * ► January (5)* ► 2015 (48)
* ► December (2) * ► November (2) * ► October (3)* ► September
(3)
* ► August (3)
* ► July (5)
* ► June (5)
* ► May (4)
* ► April (8)
* ► March (5)
* ► February (4) * ► January (4)* ► 2014 (63)
* ► December (6) * ► November (2) * ► October (6)* ► September
(6)
* ► August (4)
* ► July (3)
* ► June (6)
* ► May (6)
* ► April (2)
* ► March (6)
* ► February (9) * ► January (7)* ► 2013 (59)
* ► December (7) * ► November (5) * ► October (7)* ► September
(6)
* ► August (3)
* ► July (6)
* ► June (6)
* ► May (7)
* ► April (3)
* ► March (2)
* ► February (3) * ► January (4)* ► 2012 (62)
* ► December (6) * ► November (3) * ► October (6)* ► September
(11)
* ► August (2)
* ► July (5)
* ► June (2)
* ► May (4)
* ► April (4)
* ► March (8)
* ► February (7) * ► January (4)* ► 2011 (42)
* ► December (2) * ► November (2) * ► October (1)* ► September
(4)
* ► August (2)
* ► July (1)
* ► June (8)
* ► May (4)
* ► April (3)
* ► March (8)
* ► February (5) * ► January (2)* ► 2010 (6)
* ► November (4) * ► October (2)* ► 2009 (5)
* ► December (1) * ► November (4)MY CERTIFICATIONS
UNIQUE VISITORS
1,102,038
LABELS
* .NET Core
(30)
* .NET Framework
(232)
* ADO.NET
(8)
* Android
(2)
* AngularJS
(6)
* Apps for SharePoint(4)
* ASP.NET
(49)
* ASP.NET Core
(37)
* ASP.NET Web API
(6)
* Azure
(11)
* Bing Maps
(5)
* Business Intelligence(2)
* C/C++
(5)
* C# (248)
* Docker
(15)
* EF Core
(4)
* Entity Framework Core(2)
* Exchange 2010
(1)
* Eye Tracking
(2)
* Face Recognition
(2)
* Face Tracking
(2)
* FBCMD
(1)
* GitHub
(1)
* InfoPath
(4)
* IronPython
(1)
* JavaScript
(3)
* jQuery
(5)
* Kubernetes
(4)
* MacOS
(4)
* Microsoft
(61)
* Microsoft SQL Server(28)
* Microsoft Sync Framework(4)
* Microsoft Visual Studio(22)
* Miscellaneous
(1)
* React
(3)
* Scripting Languages(2)
* Sessions
(28)
* SharePoint
(24)
* SharePoint 2010
(20)
* Silverlight
(15)
* Syncfusion
(1)
* TechNet Wiki
(98)
* TypeScript
(3)
* WCF (18)
* Windows Runtime Apps(35)
Jaliya Udagedara. Awesome Inc. theme. Powered by Blogger.
Details
Copyright © 2024 ArchiveBay.com. All rights reserved. Terms of Use | Privacy Policy | DMCA | 2021 | Feedback | Advertising | RSS 2.0