https:\/\/msdn.microsoft.com\/en-us\/library\/windowsazure\/jj672979.aspx<\/a><\/strong><\/p>\n\n\n\nThe 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\nConfigure SQL Server to Use Local SSD<\/strong><\/h3>\n\n\n\nConnect 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\n6. 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\nIn File Explorer, create a new folder here:\u00a0C:\\SQLServerFiles\\TEMPDBSetup<\/strong><\/p>\n\n\n\nCopy 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\nLaunch 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\nIn the Create Basic Task Wizard, type\u00a0TempDBInit\u00a0<\/strong>for the name and click\u00a0Next<\/strong><\/p>\n\n\n\nOn the Task Trigger screen, select the radio button next to\u00a0When the computer starts\u00a0<\/strong>then click\u00a0Next<\/strong><\/p>\n\n\n\nOn the Action screen, select the radio button next to\u00a0Start a program\u00a0<\/strong>then click\u00a0Next<\/strong><\/p>\n\n\n\nOn 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\nOn 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\nOn 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\nIn 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\nOpen the Services Snap-in by going to Start > and typing:\u00a0Services.msc<\/strong><\/p>\n\n\n\nRight-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\nTest your Configuration<\/strong><\/h3>\n\n\n\nFrom the SQL Server Configuration Manager, stop both the SQL Server and the SQL Server Agent<\/p>\n\n\n\n <\/figure>\n\n\n\nNavigate to the root of the D:\\ drive and delete the\u00a0SQLTEMP\u00a0<\/strong>folder<\/p>\n\n\n\nRestart\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\nOpen 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\nIf SQL Server is configured correctly your output should look like this:\u00a0<\/p>\n\n\n\n <\/figure>\n\n\n\nThanks 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":"\n
Configuring TempDB on Azure IaaS for SQL Server - Navisite<\/title>\n \n \n \n \n \n \n \n \n \n \n \n \n\t \n\t \n\t \n \n \n \n \n \n\t \n\t \n\t \n