{"id":3307,"date":"2017-08-16T16:47:01","date_gmt":"2017-08-16T16:47:01","guid":{"rendered":"https:\/\/209.235.70.100\/?p=3307"},"modified":"2019-12-28T21:58:42","modified_gmt":"2019-12-28T21:58:42","slug":"configuring-tempdb-on-azure-iaas-for-sql-server","status":"publish","type":"post","link":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/","title":{"rendered":"Configuring TempDB on Azure IaaS for SQL Server"},"content":{"rendered":"\n

I am asked by clients\/team members\/friends a lot about how to set up TEMPDB to use the D:\\ drive on an Azure VM for SQL Server. Below are the steps I took to configure it on my VMs. First, read the section \u201cTemporary Disk,\u201d then decide on where to place your TempDB. Temporary disk \u2013 AKA D:\\ on Azure VM\u2019s<\/strong> Remember, this disk is, as the title of this section says, TEMPORARY<\/strong>! Do not<\/em> put anything<\/em> on this drive you cannot afford to lose. Don\u2019t say nobody warned you either, because the drive itself contains a nice little txt file warning you. Here is the exact text:
<\/p>\n\n\n\n

WARNING : THIS IS A TEMPORARY DISK.<\/strong><\/p>\n\n\n\n

Any data stored on this drive is SUBJECT TO LOSS and THERE IS NO WAY TO RECOVER IT.<\/strong><\/p>\n\n\n\n

Please do not use this disk for storing any personal or application data.<\/strong><\/p>\n\n\n\n

For additional details, please refer to the MSDN documentation at :https:\/\/msdn.microsoft.com\/en-us\/library\/windowsazure\/jj672979.aspx<\/a><\/strong><\/p>\n\n\n\n

The temporary storage drive, labeled as the D:\\ drive, is not <\/strong>persisted to Azure blob storage. Do not<\/strong> store your user database files or user transaction log files on the D:\\ drive. For D-series, Dv2-series, and G-series VMs, the temporary drive on these VMs is SSD-based. If your workload makes heavy use of TempDB (e.g. for temporary objects or complex joins), storing TempDB on the D:\\ drive could result in higher TempDB throughput and lower TempDB latency. For VMs that support Premium Storage (DS-series, DSv2-series, and GS-series), we recommend storing TempDB on a disk that supports premium storage with read caching enabled. There is one exception to this recommendation: if your TempDB usage is write-intensive, you can achieve higher performance by storing TempDB on the local D:\\ drive, which is also SSD-based on these machine sizes.<\/p>\n\n\n\n

Configure SQL Server to Use Local SSD<\/strong><\/h3>\n\n\n\n
  • Connect to your VM in Azure<\/li>
  • Create a new directory in the root of the D:\\ drive called SQLTEMP (You have to create a folder as you will not have permissions to write directly to the root of D:\\)<\/li>
  • Launch SQL Server Management Studio and connect to the SQL instance<\/li>
  • Launch a new query window by clicking the New Query button<\/li>
  • Configure the TempDB system database to store data and log files on the D:\\ drive. Cut and paste the following code into the query window then click the execute button

    USE MASTER
    GO
    ALTER DATABASE tempdb MODIFY FILE (NAME= tempdev, FILENAME= \u2018D:\\SQLTEMP\\tempdb.mdf\u2019)
    GO
    ALTER DATABASE tempdb MODIFY FILE (name = templog, filename = \u2018D:\\SQLTEMP\\templog.ldf\u2019)
    GO<\/code><\/li><\/ul>\n\n\n\n

    6. In Management Studio, right click the server icon and choose Restart. Click the Yes button on each of the confirmation popups 7. In File Explorer, navigate to the D:\\SQLTEMP directory you created earlier. You should now see two files for TempDB in the folder.<\/p>\n\n\n\n

    Configure Windows Server Startup to Prepare the SSD<\/strong><\/p>\n\n\n\n

    In File Explorer, create a new folder here:\u00a0C:\\SQLServerFiles\\TEMPDBSetup<\/strong><\/p>\n\n\n\n

    Copy and paste the following code into a new file and save the file to\u00a0C:\\SQLServerFiles\\TEMPDBSetup\\SQLTEMPDBInit.ps1<\/strong><\/p>\n\n\n\n

    $SQLService=\"SQL Server (MSSQLSERVER)\"\n$SQLAgentService=\"SQL Server Agent (MSSQLSERVER)\"\n$tempfolder=\"D:\\SQLTEMP\"\nif (!(test-path -path $tempfolder)) { `\nNew-Item -ItemType directory -Path $tempfolder `\n}\nStart-Service $SQLService\nStart-Service $SQLAgentService<\/code><\/pre>\n\n\n\n

    Launch PowerShell as Administrator. Run the following code to change the execution policy to RemoteSigned and type Y to confirm Set-ExecutionPolicy RemoteSigned<\/p>\n\n\n\n

    Launch the Windows Task Scheduler by navigating to the Start screen, click Administrative Tools, then double-click Task Scheduler<\/p>\n\n\n\n

    In the Task Scheduler, click\u00a0Create Basic Task<\/strong>\u2026 on the Actions pane<\/p>\n\n\n\n

    \"\"<\/figure>\n\n\n\n

    In the Create Basic Task Wizard, type\u00a0TempDBInit\u00a0<\/strong>for the name and click\u00a0Next<\/strong><\/p>\n\n\n\n

    On the Task Trigger screen, select the radio button next to\u00a0When the computer starts\u00a0<\/strong>then click\u00a0Next<\/strong><\/p>\n\n\n\n

    On the Action screen, select the radio button next to\u00a0Start a program\u00a0<\/strong>then click\u00a0Next<\/strong><\/p>\n\n\n\n

    On the Start a program screen, type\u00a0powershell\u00a0<\/strong>for the Program\/script and\u00a0-file \u201cC:\\SQLServerFiles\\TEMPDBSetup<\/strong>\\SQLTEMPDBInit.ps1\u2033\u00a0<\/strong>for the Add arguments then click\u00a0Next<\/strong><\/p>\n\n\n\n

    \"\"<\/figure>\n\n\n\n

    On the summary page, check the box next to\u00a0Open the Properties dialog for this task when I click Finish\u00a0<\/strong>and click\u00a0Finish<\/strong><\/p>\n\n\n\n

    On the Properties screen, click the\u00a0Change User or Group\u00a0<\/strong>button and type\u00a0SYSTEM<\/strong>\u00a0for the name and click\u00a0OK<\/strong>, change\u00a0Configure for<\/strong>\u00a0to Windows Server 2016. Click\u00a0OK<\/strong>\u00a0to save the changes<\/p>\n\n\n\n

    \"\"<\/figure>\n\n\n\n

    In the Task Scheduler, click on\u00a0Task Scheduler (Local),<\/strong>\u00a0then scroll down to\u00a0Active Tasks<\/strong>\u00a0and verify that your task was created and activated. Then close the Task Manager<\/p>\n\n\n\n

    \"\"<\/figure>\n\n\n\n

    Open the Services Snap-in by going to Start > and typing:\u00a0Services.msc<\/strong><\/p>\n\n\n\n

    Right-Click on your SQL Server (Instance Name) service<\/p>\n\n\n\n

    Go to properties and left click<\/p>\n\n\n\n

    Change the startup type to:\u00a0Automatic(Delayed Start)<\/strong><\/p>\n\n\n\n

    Test your Configuration<\/strong><\/h3>\n\n\n\n

    From the SQL Server Configuration Manager, stop both the SQL Server and the SQL Server Agent<\/p>\n\n\n\n

    \"\"<\/figure>\n\n\n\n

    Navigate to the root of the D:\\ drive and delete the\u00a0SQLTEMP\u00a0<\/strong>folder<\/p>\n\n\n\n

    Restart\u00a0Windows by right-clicking the Windows Start button and clicking Restart<\/p>\n\n\n\n

    Give the virtual machine about five minutes to restart then log back in.<\/p>\n\n\n\n

    Navigate back to the D: drive and verify that your\u00a0SQLTEMP\u00a0<\/strong>directory was recreated.<\/p>\n\n\n\n

    Open SQL Server Management Studio and execute the following query to verify that tempdb is running with files located on the D:\\ drive<\/p>\n\n\n\n

    SELECT dbid, name, filename FROM sys.sysaltfiles WHERE dbid = 2<\/strong><\/pre>\n\n\n\n

    If SQL Server is configured correctly your output should look like this:\u00a0<\/p>\n\n\n\n

    \"\"<\/figure>\n\n\n\n

    Thanks for reading everybody!  Stay tuned for more posts about Azure soon.<\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":114,"featured_media":3317,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"acf":[],"yoast_head":"\nConfiguring TempDB on Azure IaaS for SQL Server - Navisite<\/title>\n<meta name=\"description\" content=\"I am asked by clients\/team members\/friends a lot about how to set up TEMPDB to use the D: drive on an Azure VM for SQL Server. Below are the steps I took\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Configuring TempDB on Azure IaaS for SQL Server\" \/>\n<meta property=\"og:description\" content=\"I am asked by clients\/team members\/friends a lot about how to set up TEMPDB to use the D: drive on an Azure VM for SQL Server. Below are the steps I took\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/\" \/>\n<meta property=\"og:site_name\" content=\"Navisite\" \/>\n<meta property=\"article:published_time\" content=\"2017-08-16T16:47:01+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-12-28T21:58:42+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.navisite.com\/wp-content\/uploads\/2019\/12\/ConfiguringTempDB.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"815\" \/>\n\t<meta property=\"og:image:height\" content=\"463\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Megan Ferringer\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@navisite\" \/>\n<meta name=\"twitter:site\" content=\"@navisite\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Megan Ferringer\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/\"},\"author\":{\"name\":\"Megan Ferringer\",\"@id\":\"https:\/\/www.navisite.com\/#\/schema\/person\/99bad6e33cc6d3ac27337400026e4a9f\"},\"headline\":\"Configuring TempDB on Azure IaaS for SQL Server\",\"datePublished\":\"2017-08-16T16:47:01+00:00\",\"dateModified\":\"2019-12-28T21:58:42+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/\"},\"wordCount\":868,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.navisite.com\/#organization\"},\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/\",\"url\":\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/\",\"name\":\"Configuring TempDB on Azure IaaS for SQL Server - Navisite\",\"isPartOf\":{\"@id\":\"https:\/\/www.navisite.com\/#website\"},\"datePublished\":\"2017-08-16T16:47:01+00:00\",\"dateModified\":\"2019-12-28T21:58:42+00:00\",\"description\":\"I am asked by clients\/team members\/friends a lot about how to set up TEMPDB to use the D:\\\\ drive on an Azure VM for SQL Server. Below are the steps I took\",\"breadcrumb\":{\"@id\":\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.navisite.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Configuring TempDB on Azure IaaS for SQL Server\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.navisite.com\/#website\",\"url\":\"https:\/\/www.navisite.com\/\",\"name\":\"Navisite\",\"description\":\"Elevate Your Cloud Journey\",\"publisher\":{\"@id\":\"https:\/\/www.navisite.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.navisite.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.navisite.com\/#organization\",\"name\":\"Navisite\",\"url\":\"https:\/\/www.navisite.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.navisite.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.navisite.com\/wp-content\/uploads\/2020\/02\/logo.svg\",\"contentUrl\":\"https:\/\/www.navisite.com\/wp-content\/uploads\/2020\/02\/logo.svg\",\"width\":1,\"height\":1,\"caption\":\"Navisite\"},\"image\":{\"@id\":\"https:\/\/www.navisite.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/twitter.com\/navisite\",\"https:\/\/www.instagram.com\/navisite\/\",\"https:\/\/www.linkedin.com\/company\/navisite\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.navisite.com\/#\/schema\/person\/99bad6e33cc6d3ac27337400026e4a9f\",\"name\":\"Megan Ferringer\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.navisite.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.navisite.com\/wp-content\/uploads\/2021\/02\/IMG-0529-150x150.jpg\",\"contentUrl\":\"https:\/\/www.navisite.com\/wp-content\/uploads\/2021\/02\/IMG-0529-150x150.jpg\",\"caption\":\"Megan Ferringer\"},\"description\":\"Megan is the Content Marketing Manager at Navisite with more than 10 years of experience helping brands discover and tell their stories. From working at a global non-profit organization to boutique marketing agencies in Chicago, she champions the power of storytelling across all industries.\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Configuring TempDB on Azure IaaS for SQL Server - Navisite","description":"I am asked by clients\/team members\/friends a lot about how to set up TEMPDB to use the D: drive on an Azure VM for SQL Server. Below are the steps I took","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/","og_locale":"en_US","og_type":"article","og_title":"Configuring TempDB on Azure IaaS for SQL Server","og_description":"I am asked by clients\/team members\/friends a lot about how to set up TEMPDB to use the D: drive on an Azure VM for SQL Server. Below are the steps I took","og_url":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/","og_site_name":"Navisite","article_published_time":"2017-08-16T16:47:01+00:00","article_modified_time":"2019-12-28T21:58:42+00:00","og_image":[{"width":815,"height":463,"url":"https:\/\/www.navisite.com\/wp-content\/uploads\/2019\/12\/ConfiguringTempDB.jpg","type":"image\/jpeg"}],"author":"Megan Ferringer","twitter_card":"summary_large_image","twitter_creator":"@navisite","twitter_site":"@navisite","twitter_misc":{"Written by":"Megan Ferringer","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/#article","isPartOf":{"@id":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/"},"author":{"name":"Megan Ferringer","@id":"https:\/\/www.navisite.com\/#\/schema\/person\/99bad6e33cc6d3ac27337400026e4a9f"},"headline":"Configuring TempDB on Azure IaaS for SQL Server","datePublished":"2017-08-16T16:47:01+00:00","dateModified":"2019-12-28T21:58:42+00:00","mainEntityOfPage":{"@id":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/"},"wordCount":868,"commentCount":0,"publisher":{"@id":"https:\/\/www.navisite.com\/#organization"},"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/","url":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/","name":"Configuring TempDB on Azure IaaS for SQL Server - Navisite","isPartOf":{"@id":"https:\/\/www.navisite.com\/#website"},"datePublished":"2017-08-16T16:47:01+00:00","dateModified":"2019-12-28T21:58:42+00:00","description":"I am asked by clients\/team members\/friends a lot about how to set up TEMPDB to use the D:\\ drive on an Azure VM for SQL Server. Below are the steps I took","breadcrumb":{"@id":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.navisite.com\/blog\/configuring-tempdb-on-azure-iaas-for-sql-server\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.navisite.com\/"},{"@type":"ListItem","position":2,"name":"Configuring TempDB on Azure IaaS for SQL Server"}]},{"@type":"WebSite","@id":"https:\/\/www.navisite.com\/#website","url":"https:\/\/www.navisite.com\/","name":"Navisite","description":"Elevate Your Cloud Journey","publisher":{"@id":"https:\/\/www.navisite.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.navisite.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.navisite.com\/#organization","name":"Navisite","url":"https:\/\/www.navisite.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.navisite.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.navisite.com\/wp-content\/uploads\/2020\/02\/logo.svg","contentUrl":"https:\/\/www.navisite.com\/wp-content\/uploads\/2020\/02\/logo.svg","width":1,"height":1,"caption":"Navisite"},"image":{"@id":"https:\/\/www.navisite.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/twitter.com\/navisite","https:\/\/www.instagram.com\/navisite\/","https:\/\/www.linkedin.com\/company\/navisite"]},{"@type":"Person","@id":"https:\/\/www.navisite.com\/#\/schema\/person\/99bad6e33cc6d3ac27337400026e4a9f","name":"Megan Ferringer","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.navisite.com\/#\/schema\/person\/image\/","url":"https:\/\/www.navisite.com\/wp-content\/uploads\/2021\/02\/IMG-0529-150x150.jpg","contentUrl":"https:\/\/www.navisite.com\/wp-content\/uploads\/2021\/02\/IMG-0529-150x150.jpg","caption":"Megan Ferringer"},"description":"Megan is the Content Marketing Manager at Navisite with more than 10 years of experience helping brands discover and tell their stories. From working at a global non-profit organization to boutique marketing agencies in Chicago, she champions the power of storytelling across all industries."}]}},"publishpress_future_action":{"enabled":false,"date":"1970-01-01 00:00:00","action":"","terms":[],"taxonomy":"","browser_timezone_offset":0},"_links":{"self":[{"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/posts\/3307"}],"collection":[{"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/users\/114"}],"replies":[{"embeddable":true,"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/comments?post=3307"}],"version-history":[{"count":0,"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/posts\/3307\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/media\/3317"}],"wp:attachment":[{"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/media?parent=3307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/categories?post=3307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.navisite.com\/wp-json\/wp\/v2\/tags?post=3307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}