How To Put Tempdb On Your Azure VM Temp Disk
How To Put Tempdb On Your Azure VM Temp Disk
1 of 8 8/9/23, 08:41
How to put tempdb on your Azure VM temp disk | sql... https://sqlsunday.com/2023/04/10/set-up-tempdb-on-v...
Step by step
2 of 8 8/9/23, 08:41
How to put tempdb on your Azure VM temp disk | sql... https://sqlsunday.com/2023/04/10/set-up-tempdb-on-v...
1 # Configuration
2
3 $SQLService="SQL Server (MSSQLSERVER)"
4 $SQLAgentService="SQL Server Agent (MSSQLSERVER)"
5 $tempdbFolder="D:\tempdb"
6
7 # Make tempdb directory on the SSD
8
9 if (!(Test-Path -Path $tempdbFolder)) {
10 New-Item -ItemType Directory -Path $tempdbFolder
11 }
12
13 # Start the services
14
15 Start-Service $SQLService
16 Start-Service $SQLAgentService
3 of 8 8/9/23, 08:41
How to put tempdb on your Azure VM temp disk | sql... https://sqlsunday.com/2023/04/10/set-up-tempdb-on-v...
4 of 8 8/9/23, 08:41
How to put tempdb on your Azure VM temp disk | sql... https://sqlsunday.com/2023/04/10/set-up-tempdb-on-v...
Make sure you spell the directory correctly and that SQL Server
has permissions to create files in that directory. Otherwise, the
instance won’t start at all.
Other solutions
AZURE VM ,
TEMPDB ,
TEMPORARY DISK
1. Jeff Moden
2023-04-10 AT 15:48
I’m not a Azure user.. not sure that I ever will be… but it it ever
5 of 8 8/9/23, 08:41
How to put tempdb on your Azure VM temp disk | sql... https://sqlsunday.com/2023/04/10/set-up-tempdb-on-v...
REPLY
◦ Daniel Hutmacher
2023-04-10 AT 16:18
Thanks, Jeff! I appreciate your kind words. :)
REPLY
2. Peter Åkerlund
2023-04-10 AT 19:50
Have been using a Joeys script for some time but intefesting
point about the page file. Something to look into.
REPLY
3. Pingback: Putting tempdb on an Azure VM Temp Disk –
Curated SQL
4. David Wiseman
2023-04-17 AT 12:52
Another option is to use the IaaS agent extension.
https://www.sqltact.com/2020/05/azure-vm-tempdb-on-d.html
REPLY
◦ Steve Welburn
2023-04-18 AT 10:30
Yup, that makes life much easier. Sounds like MS need to
advertise the benefits of the extension a bit more!
REPLY
5. Aaron Blosser
2023-04-17 AT 19:50
I had created a script that does exactly this, plus makes sure
the appropriate permissions are granted to the service
account. It works great. And then we tried out the SQL IaaS
extension which supposedly will do this same thing, and it
works sometimes. But when it doesn’t work (the extension
may have issues during machine startup), it results in SQL not
starting because your TempDB folder isn’t present where it
expects.
6 of 8 8/9/23, 08:41
How to put tempdb on your Azure VM temp disk | sql... https://sqlsunday.com/2023/04/10/set-up-tempdb-on-v...
REPLY
6. Tim Gitchel
2023-04-18 AT 13:46
Here is a snippet of my script to setup the ephemeral drive for
TempDB on AWS EC2 instances. The script is called from
user data.
if ($NVMe) {
New-StoragePool -FriendlyName NVMePool
-StorageSubsystemFriendlyName “Windows Storage*”
-PhysicalDisks $NVMe
}
$driveLetters= (Get-Volume).DriveLetter
7 of 8 8/9/23, 08:41
How to put tempdb on your Azure VM temp disk | sql... https://sqlsunday.com/2023/04/10/set-up-tempdb-on-v...
$item.SetAccessControl($acl)
New-Item -Path “T:\Data” -ItemType Directory
New-Item -Path “T:\Logs” -ItemType Directory
}
REPLY
◦ Tim Gitchel
2023-04-18 AT 16:34
This will set the T drive to roughly 2/3 of the ephemeral
disk space and the E drive to roughly the remaining 1/3.
REPLY
8 of 8 8/9/23, 08:41