<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Vedant</title>
    <description>The latest articles on DEV Community by Vedant (@koditkarvedant).</description>
    <link>https://dev.to/koditkarvedant</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F729805%2Fa9ee0488-d17b-4ece-9491-6e70152a3234.png</url>
      <title>DEV Community: Vedant</title>
      <link>https://dev.to/koditkarvedant</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/koditkarvedant"/>
    <language>en</language>
    <item>
      <title>Setup NAS on Raspberry Pi 4 - Part 3</title>
      <dc:creator>Vedant</dc:creator>
      <pubDate>Fri, 31 Dec 2021 20:23:02 +0000</pubDate>
      <link>https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f</link>
      <guid>https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f</guid>
      <description>&lt;p&gt;You are reading the third part of the multi part series to Setup NAS on Raspberry Pi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6"&gt;Part 1: Motivation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p"&gt;Part 2: Bake the Pi&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f"&gt;Part 3: Install OpenMediaVault&lt;/a&gt;&lt;br&gt;
Part 4: Setup OpenMediaVault &lt;strong&gt;(coming soon...)&lt;/strong&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Part 3: Install OpenMediaVault
&lt;/h2&gt;

&lt;p&gt;First thing first we need to make sure Raspberry PI is up to date.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;apt update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nb"&gt;sudo &lt;/span&gt;apt upgrade
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Sit tight this is gonna take some a little bit.&lt;/p&gt;

&lt;p&gt;Now we can run the following command to download the OpenMediatVaulty install script and pipe it directly through to bash. This script will install everthing need to run OpenMediaVault on the Raspberry Pi.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;wget &lt;span class="nt"&gt;-O&lt;/span&gt; - https://raw.githubusercontent.com/OpenMediaVault-Plugin-Developers/installScript/master/install | &lt;span class="nb"&gt;sudo &lt;/span&gt;bash
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This script will do ton of packages that the OpenMediaVault software requires. So keep your coffee or poison ready. ☕☕☕&lt;/p&gt;

&lt;p&gt;After installation is done if you did not get disconnected from Raspberry Pi then you might wanna restart the Pi manually.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;reboot
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Setup OpenMediaVault
&lt;/h2&gt;

&lt;p&gt;As in previous step you have restarted the Raspberry Pi which result in new IP address got assigned to the device. So you need to find the through home router.&lt;/p&gt;

&lt;p&gt;Now let's configure OpenMediaVault.&lt;/p&gt;

&lt;p&gt;Open your favorite browser and enter the below address.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;http://192.168.0.30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You might see login screen something like below or something different as per the version of OpenMediaVault you've got.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfeqvar7knwfkt2oojzz.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhfeqvar7knwfkt2oojzz.png" alt="OpenMediaVault login screen"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Below are default credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;username: admin
password: openmediavault
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once you logged in you should be landed on Dashboard page.&lt;/p&gt;




&lt;p&gt;That is it for this part you can continue with the reading the rest of parts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6"&gt;Part 1: Motivation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p"&gt;Part 2: Bake the Pi&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f"&gt;Part 3: Install OpenMediaVault&lt;/a&gt;&lt;br&gt;
Part 4: Setup OpenMediaVault &lt;strong&gt;(coming soon...)&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>raspberrypi</category>
      <category>nas</category>
      <category>openmediavault</category>
    </item>
    <item>
      <title>Setup NAS on Raspberry Pi 4 - Part 2</title>
      <dc:creator>Vedant</dc:creator>
      <pubDate>Fri, 31 Dec 2021 20:22:58 +0000</pubDate>
      <link>https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p</link>
      <guid>https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p</guid>
      <description>&lt;p&gt;You are reading the second part of the multi part series to Setup NAS on Raspberry Pi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6"&gt;Part 1: Motivation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p"&gt;Part 2: Bake the Pi&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f"&gt;Part 3: Install OpenMediaVault&lt;/a&gt;&lt;br&gt;
Part 4: Setup OpenMediaVault &lt;strong&gt;(coming soon...)&lt;/strong&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Part 2: Bake the PI
&lt;/h2&gt;

&lt;p&gt;So, Let's setup on Raspberry PI. I've used Raspberry PI 4 Model B 4 GB. You may use any other variant of the device.&lt;/p&gt;

&lt;p&gt;First of all we need to install operating system on your Raspberry PI device. For that attach the SD Card to your Desktop/Laptop using card reader.&lt;/p&gt;

&lt;p&gt;Download and install Raspberry Pi Imager to a computer &lt;a href="https://www.raspberrypi.com/software/" rel="noopener noreferrer"&gt;https://www.raspberrypi.com/software/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Put the SD card you'll use with your Raspberry Pi into the reader and run Raspberry Pi Imager.&lt;/p&gt;

&lt;p&gt;Open Raspberry Pi Imager.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8zkjb14ujxzk1avgo1k.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fm8zkjb14ujxzk1avgo1k.png" alt="Raspberry Pi Imager GUI"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Click on &lt;code&gt;CHOOSE OS&lt;/code&gt; button then select &lt;code&gt;Raspberry Pi OS (other)&lt;/code&gt; option.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99vr4mz9e9gfvu2so17j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F99vr4mz9e9gfvu2so17j.png" alt="Raspberry Pi image selection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Select &lt;code&gt;Raspberry Pi OS Lite (32-bit)&lt;/code&gt;. This will be just fine for us as we don't need a GUI.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yfutbvgjx9tmnioy7a7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5yfutbvgjx9tmnioy7a7.png" alt="Raspberry Pi OS Lite image selection"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now click on &lt;code&gt;CHOOSE STORAGE&lt;/code&gt; and select the SD Card you have attached to the computer.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Warning: make sure you select the correct device as this step will erase any data on the device.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;One more thing before we write we have to enable the ssh. For that press &lt;code&gt;ctrl + shift + x&lt;/code&gt; this will open below Advance options window.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6md9h5kum0j13g6qisgw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6md9h5kum0j13g6qisgw.png" alt="Advance options"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As you can see above check &lt;code&gt;Enable SSH&lt;/code&gt; and select &lt;code&gt;Use password authentication&lt;/code&gt; (you may select public-key authentication if need) then insert the password which you will need to ssh into the device later.&lt;/p&gt;

&lt;p&gt;Click on &lt;code&gt;WRITE&lt;/code&gt; button to install the OS on SD card.&lt;/p&gt;

&lt;p&gt;This will take some time. It will download the Image from server if it is not already cached so take a coffee break. &lt;/p&gt;

&lt;p&gt;☕☕☕&lt;/p&gt;
&lt;h3&gt;
  
  
  Connect Raspberry PI using ssh
&lt;/h3&gt;

&lt;p&gt;Insert the Memory card in Raspberry Pi. Connect the power cable and attach the Raspberry Pi to network using ethernet cable.&lt;/p&gt;

&lt;p&gt;Now we are going to access and log into Raspberry Pi via SSH, but to do that we need to know the IP address. How can we find the IP address? the easiest way is to check your home router. Your home router will give out and IP address to your Raspberry Pi via DHCP, just look at the last device that signed in and got and IP address for me.&lt;/p&gt;

&lt;p&gt;Most probably the connected &lt;code&gt;device type&lt;/code&gt;/&lt;code&gt;model&lt;/code&gt; will be named Raspberry Pi.&lt;/p&gt;

&lt;p&gt;Now once we have IP address in my case it is &lt;code&gt;192.168.0.30&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now lets &lt;code&gt;ssh&lt;/code&gt; into the device. Open terminal and run the below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh pi@192.168.0.30
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This will ask you &lt;code&gt;Are you want to continue connection?&lt;/code&gt; just put &lt;code&gt;yes&lt;/code&gt;. It will ask you to insert password, insert the one you set earlier else default would be &lt;code&gt;raspberry&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now you should be in.&lt;/p&gt;




&lt;p&gt;That is it for this part you can continue with the reading the rest of parts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6"&gt;Part 1: Motivation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p"&gt;Part 2: Bake the Pi&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f"&gt;Part 3: Install OpenMediaVault&lt;/a&gt;&lt;br&gt;
Part 4: Setup OpenMediaVault &lt;strong&gt;(coming soon...)&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>linux</category>
      <category>raspberrypi</category>
      <category>nas</category>
      <category>openmediavault</category>
    </item>
    <item>
      <title>Setup NAS on Raspberry Pi 4 - Part 1</title>
      <dc:creator>Vedant</dc:creator>
      <pubDate>Fri, 31 Dec 2021 20:22:55 +0000</pubDate>
      <link>https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6</link>
      <guid>https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6</guid>
      <description>&lt;p&gt;This will be multi part post where I will take you through understanding what is NAS? How to setup NAS on your own using Raspberry Pi.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6"&gt;Part 1: Motivation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p"&gt;Part 2: Bake the Pi&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f"&gt;Part 3: Install OpenMediaVault&lt;/a&gt;&lt;br&gt;
Part 4: Setup OpenMediaVault &lt;strong&gt;(coming soon...)&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Part 1: Motivation
&lt;/h2&gt;

&lt;p&gt;Recently I felt a need to have NAS which I can access on my local network and eventually expose it over internet for things like backing up my photos, videos, backups etc. &lt;/p&gt;

&lt;p&gt;But I was hoping it to be more than just a regular NAS. I want it to run other services likes password manager, media player server which I can access on my mobile phone, tv and other devices.&lt;/p&gt;

&lt;p&gt;Buying NAS is a good option but it is very costly. So I decided to build one myself. &lt;/p&gt;

&lt;p&gt;This multi-part post is share my experience and steps I followed to setup one for myself.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is a NAS Server?
&lt;/h3&gt;

&lt;p&gt;A (Network Attached Storage) NAS Server is a network storage system to serve and share files to other client computers in a local area network. This enables multiple users to access and share the same file storage.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why NAS Server on Raspberry Pi?
&lt;/h3&gt;

&lt;p&gt;Raspberry Pi is a mini-computer with the full performance of a Linux-based operating system and contains almost all functions of a large server system.&lt;/p&gt;

&lt;p&gt;The Raspberry Pi saves a lot of money because it consumes a very small amount of energy. Due to its small size, the Raspberry Pi can be placed on nearly any place.&lt;/p&gt;

&lt;p&gt;There are various solutions present which can help you build your NAS. I will be using openmediavault.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is OpenMediaVault?
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9ohfm2e6z8yu4kuiixj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl9ohfm2e6z8yu4kuiixj.png" alt="open media vault logo"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;openmediavault is the next generation network attached storage (NAS) solution based on Debian Linux. It contains services like SSH, (S)FTP, SMB/CIFS, DAAP media server, RSync, BitTorrent client and many more. &lt;/p&gt;

&lt;p&gt;openmediavault is primarily designed to be used in small offices or home offices, but is not limited to those scenarios. It is a simple and easy to use out-of-the-box solution that will allow everyone to install and administrate a Network Attached Storage without deeper knowledge.&lt;/p&gt;

&lt;p&gt;You can read about the features provided by OpenMediaVault &lt;a href="https://www.openmediavault.org/?page_id=1562" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;That is it for this part you can continue with the reading the rest of parts.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-4-part-1-1pp6"&gt;Part 1: Motivation&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-2-37p"&gt;Part 2: Bake the Pi&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/koditkarvedant/setup-nas-on-raspberry-pi-part-3-4m9f"&gt;Part 3: Install OpenMediaVault&lt;/a&gt;&lt;br&gt;
Part 4: Setup OpenMediaVault &lt;strong&gt;(coming soon...)&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>nas</category>
      <category>raspberrypi</category>
      <category>linux</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Connect to Local SQL Server from Docker container</title>
      <dc:creator>Vedant</dc:creator>
      <pubDate>Tue, 19 Oct 2021 04:42:47 +0000</pubDate>
      <link>https://dev.to/koditkarvedant/connect-to-local-sql-server-from-docker-container-1hob</link>
      <guid>https://dev.to/koditkarvedant/connect-to-local-sql-server-from-docker-container-1hob</guid>
      <description>&lt;p&gt;In this post, I will show you how to connect from an app running in a docker container to a local SQL express/server running in your machine.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Please note that the SQL Server is not running inside a docker container but it is installed on my dev machine.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Recently, I was considering using the docker for my day to day development. So I can deploy all the services which are required in docker and keep them up all the time and only redeploy the changed services.&lt;/p&gt;

&lt;p&gt;Deploying other app services is easy but things go complicated with the database. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Well not to mention that I could deploy a database in a docker container and use it instead but then I will be running one instance on my local machine and another on the container.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  What is the problem?
&lt;/h2&gt;

&lt;p&gt;The docker container is running as a separate machine inside your host machine. Hence the Data Source=(local) or named server is not the same when the app runs inside the docker.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;p&gt;To solve this problem, we need to enable the TCP/IP protocol over the network for SQL Server to be able to access over the network so docker can connect to it.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to Enable TCP/IP protocol over a network
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;To enable TCP/IP protocol you need to open the SQL Server manager tool.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;#### Before Widows 8&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Search in Windows start for "SQL Server Configuration Manager"&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7qj2346z0fehallo8x2i.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7qj2346z0fehallo8x2i.png" alt="SQL Server Configuration Manger"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- #### Windows 8, 10 &amp;amp; newer

  - The newer Microsoft SQL Server Configuration Manager is a snap-in for the Microsoft Management Console Program.

  - It is not a stand-alone program as it used to be in the previous versions of Windows.

  | Version | Search | Path |
  |---|---|---|
  | SQL Server 2019         | SQLServerManager15.msc |  C:\Windows\SysWOW64\SQLServerManager15.msc |
  | SQL Server 2017         | SQLServerManager14.msc |  C:\Windows\SysWOW64\SQLServerManager14.msc |
  | SQL Server 2016         | SQLServerManager13.msc |  C:\Windows\SysWOW64\SQLServerManager13.msc |
  | SQL Server 2014 (12.x)  | SQLServerManager12.msc |  C:\Windows\SysWOW64\SQLServerManager12.msc |
  | SQL Server 2012 (11.x)  | SQLServerManager11.msc |  C:\Windows\SysWOW64\SQLServerManager11.msc |
  | SQL Server 2008         | SQLServerManager10.msc |  C:\Windows\SysWOW64\SQLServerManager10.msc |

  ![SQL Server Manager png](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b2ru5tjrqjopkr49no7o.png)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Open the &lt;strong&gt;SQL Server Configuration Manager (Local)&lt;/strong&gt; &amp;gt; &lt;strong&gt;SQL Server Network Configuration&lt;/strong&gt; menu and click the &lt;strong&gt;Protocols for MSSQLSERVERXXXX&lt;/strong&gt; (where XXXX is the MSSQL version).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3eosfblsjvgns6un6neu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3eosfblsjvgns6un6neu.png" alt="SQL Server Network Configuration png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If &lt;code&gt;TCP/IP&lt;/code&gt; protocol is &lt;code&gt;Disabled&lt;/code&gt; as shown in the above image then follow the below steps to enable it.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Double-click the `TCP/IP` protocol.
2. Under Protocol tab set `Enabled` property `yes`.

  ![SQL server manager network protocol png](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/asphl5tvxl6ytct8w5fg.png)

3. Click on Apply
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;ol&gt;
&lt;li&gt;Double-click the TCP/IP protocol &amp;amp; go to &lt;code&gt;IP Addresses&lt;/code&gt; to check on which TCP/IP port SQL Server is listening.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxqom03xnp23nl1oznx1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Foxqom03xnp23nl1oznx1.png" alt="SQL Server manager network protocol IP addresses tab png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;in my case, it is listening on default port &lt;code&gt;1433&lt;/code&gt;.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Now we need to restart the SQL Server so the changes we made will take effect.&lt;/p&gt;

&lt;p&gt;Go to &lt;code&gt;SQL Server Configuration Manager (Local)&lt;/code&gt; &amp;gt; &lt;code&gt;SQL Server Services&lt;/code&gt;, right-click the &lt;code&gt;SQL Server (MSSQLSERVER) service&lt;/code&gt; and press the &lt;code&gt;Restart&lt;/code&gt; button to apply changes&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkdxfixpdy94qp8qz8tk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqkdxfixpdy94qp8qz8tk.png" alt="SQL server manager restart server png"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now we are ready to use the SQL Server from the docker container.&lt;/p&gt;

&lt;h2&gt;
  
  
  But,
&lt;/h2&gt;

&lt;p&gt;There is one additional change we need to do to our connection string.&lt;/p&gt;

&lt;p&gt;You must be using the following connection string to connect to your SQL Server&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ConnectionString"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Server=myServerAddress, myPortNumber;Database=myDataBase;User Id=myUsername;Password=myPassword;"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ConnectionString"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Data Source=(local);Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You have to change the database server address to your machine's IP address but your machine has a changing IP address (or none if you have no network access).&lt;/p&gt;

&lt;p&gt;Docker 18.03 onward helps us with this with special DNS name &lt;code&gt;host.docker.internal&lt;/code&gt;, which resolves to the internal IP address used by the host machine.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is for development purposes and will not work in a production outside of Docker Desktop for Windows or Docker Desktop for Mac.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;You can now change the connection string as follows&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ConnectionString"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Server=host.docker.internal, myPortNumber;Database=myDataBase;User Id=myUsername;Password=myPassword;"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;OR&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ConnectionString"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Data Source=host.docker.internal;Initial Catalog=myDataBase;User ID=myUsername;Password=myPassword;"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>docker</category>
      <category>sqlserver</category>
      <category>dotnet</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Deploy Azure web job on Docker</title>
      <dc:creator>Vedant</dc:creator>
      <pubDate>Tue, 19 Oct 2021 04:07:48 +0000</pubDate>
      <link>https://dev.to/koditkarvedant/deploy-azure-web-job-on-docker-3cog</link>
      <guid>https://dev.to/koditkarvedant/deploy-azure-web-job-on-docker-3cog</guid>
      <description>&lt;h3&gt;
  
  
  What is WebJobs SDK?
&lt;/h3&gt;

&lt;p&gt;The Azure WebJobs SDK is a framework that simplifies the task of writing background processing code that runs in Azure WebJobs. It includes a declarative binding and trigger system that works with Azure Storage Blobs, Queues and Tables as well as Service Bus. The binding system makes it incredibly easy to write code that reads or writes Azure Storage objects. The trigger system automatically invokes a function in your code whenever any new data is received in a queue or blob.&lt;/p&gt;

&lt;p&gt;The version 3.x of the WebJobs SDK supports both .NET Core and .NET Framework console apps. This opens all sorts of possibilities of hosting it apart from App Service. In this article I'll walk you through process of hosting the Web Job on Docker.&lt;/p&gt;

&lt;h3&gt;
  
  
  Create Web job using Web Job SDK 3
&lt;/h3&gt;

&lt;p&gt;Let's create simple queue triggered web job which will print the message received in the azure queue.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;open a command prompt and enter the below command.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet new console &lt;span class="nt"&gt;-o&lt;/span&gt; &lt;span class="s2"&gt;"ContainerizedWebJob"&lt;/span&gt;
&lt;span class="nb"&gt;cd &lt;/span&gt;ContainerizedWebJob
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Install the latest stable 3.x versions of the following NuGet packages.

&lt;ul&gt;
&lt;li&gt;Microsoft.Azure.WebJobs&lt;/li&gt;
&lt;li&gt;Microsoft.Azure.WebJobs.Extensions&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here are the commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package Microsoft.Azure.WebJobs &lt;span class="nt"&gt;--version&lt;/span&gt; 3.0.11
dotnet add package Microsoft.Azure.WebJobs.Extensions &lt;span class="nt"&gt;--version&lt;/span&gt; 3.0.2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;We will need console logging using which we will print the recieved message from the queue on the console. Install the latest version of belo packages
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package Microsoft.Extensions.Logging &lt;span class="nt"&gt;--version&lt;/span&gt; 2.2.0
dotnet add package Microsoft.Extensions.Logging.Console &lt;span class="nt"&gt;--version&lt;/span&gt; 2.2.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Install storage binding extension Starting with version 3.x, you must explicitly install the Storage binding extension required by the WebJobs SDK. In prior versions, the Storage bindings were included in the SDK. Install latest version of below package
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet add package Microsoft.Azure.WebJobs.Extensions.Storage &lt;span class="nt"&gt;--version&lt;/span&gt; 3.0.7
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Now we will create the host and configure it.Add program.cs file and replace the content of with below.
&lt;/li&gt;
&lt;/ol&gt;

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

&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;ContainerizedWebJob&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Program&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Main&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;HostBuilder&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;UseEnvironment&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;EnvironmentName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Development&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConfigureWebJobs&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAzureStorageCoreServices&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
                &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAzureStorage&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConfigureLogging&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddConsole&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;


            &lt;span class="p"&gt;});&lt;/span&gt;
            &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;host&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Build&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="n"&gt;host&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Run&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add &lt;code&gt;Functions.cs&lt;/code&gt; file which will have the functions which will process the queue message.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Azure.WebJobs&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;using&lt;/span&gt; &lt;span class="nn"&gt;Microsoft.Extensions.Logging&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;namespace&lt;/span&gt; &lt;span class="nn"&gt;ContainerizedWebJob&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Functions&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;ProcessQueueMessage&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;QueueTrigger&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"message-queue"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="n"&gt;ILogger&lt;/span&gt; &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;logger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;LogInformation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add appsettings.json&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"AzureWebJobsStorage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"UseDevelopmentStorage=true"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Modify &lt;code&gt;ContainerizedWebJob.csproj&lt;/code&gt; and add new &lt;code&gt;&amp;lt;ItemGroup&amp;gt;&lt;/code&gt;.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight xml"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ItemGroup&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;None&lt;/span&gt; &lt;span class="na"&gt;Update=&lt;/span&gt;&lt;span class="s"&gt;"appsettings.json"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;CopyToOutputDirectory&amp;gt;&lt;/span&gt;Always&lt;span class="nt"&gt;&amp;lt;/CopyToOutputDirectory&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/None&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ItemGroup&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Lets run an test it.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet build
dotnet run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Create a queue named &lt;code&gt;message-queue&lt;/code&gt; add the message.&lt;/p&gt;

&lt;h3&gt;
  
  
  Deploy Web job on docker.
&lt;/h3&gt;

&lt;p&gt;To deploy this application on docker we need to specify docker configuration. Add &lt;code&gt;Dockerfile&lt;/code&gt; at the root of the application.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight docker"&gt;&lt;code&gt;&lt;span class="k"&gt;FROM&lt;/span&gt;&lt;span class="s"&gt; mcr.microsoft.com/dotnet/core/runtime:2.2&lt;/span&gt;
&lt;span class="k"&gt;WORKDIR&lt;/span&gt;&lt;span class="s"&gt; /app&lt;/span&gt;
&lt;span class="k"&gt;COPY&lt;/span&gt;&lt;span class="s"&gt; ./bin/Debug/netcoreapp2.2/publish .&lt;/span&gt;
&lt;span class="k"&gt;ENTRYPOINT&lt;/span&gt;&lt;span class="s"&gt; [ "dotnet", "ContainerizedWebJob.dll" ]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Before we deploy this app on docker we need to make changes to our &lt;code&gt;appsettings.json&lt;/code&gt; file as below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"AzureWebJobsStorage"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"UseDevelopmentStorage=true;DevelopmentStorageProxyUri=http://host.docker.internal"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; The &lt;strong&gt;Azure Storage Emulator&lt;/strong&gt; is bound in a local-only network configuration and &lt;strong&gt;Docker&lt;/strong&gt; for Windows runs in a &lt;strong&gt;VM&lt;/strong&gt; using &lt;strong&gt;Hyper-V&lt;/strong&gt;. Hence to access the emulator running on host (Windows) we need to use the proxy &lt;code&gt;http://host.docker.internal&lt;/code&gt; instead of &lt;code&gt;http://127.0.0.1&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now that we are done with all the configuration we shall create and run the docker image. To create a docker image, run the below command where you have put the &lt;code&gt;Dockerfile&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker build &lt;span class="nt"&gt;-t&lt;/span&gt; containerized-web-job
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the image is create we shall run it using below command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; containerized-web-job
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; above command will delete the container as soon as we stop the web job.&lt;/p&gt;

&lt;p&gt;You can find source code &lt;a href="https://github.com/KoditkarVedant/containerized-web-job"&gt;here&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>docker</category>
      <category>dotnet</category>
      <category>csharp</category>
      <category>azure</category>
    </item>
  </channel>
</rss>
