Download - Autodeploy när man inte kommer åt miljöerna
![Page 1: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/1.jpg)
Automatisera deployer på oåtkomliga servrar
Robin Helly, .NET-utvecklare
![Page 2: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/2.jpg)
![Page 3: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/3.jpg)
![Page 4: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/4.jpg)
![Page 5: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/5.jpg)
Shake ’n bake
![Page 6: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/6.jpg)
![Page 7: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/7.jpg)
Automatisera deployer på oåtkomliga servrar
Eller när shake ’n bake minskade kostnaderna för projektet
Robin Helly, .NET-utvecklare
![Page 8: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/8.jpg)
![Page 9: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/9.jpg)
Driftsättning
•Molnet
• Egna fysiska servrar
•Dedikerade servrar hos driftsleverantör
•Manuell deploy och autodeploy
![Page 10: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/10.jpg)
Manuell deploy hos extern driftsleverantör
• Tidskrävande för flera parter
•Driftsättarna känner inte till koden och utvecklarna känner inte till miljön
•Mänsklig faktor
•Deployerna kan skilja sig från gång till gång
![Page 11: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/11.jpg)
![Page 12: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/12.jpg)
Deploy-script
•PowerShell script
•Backup och ny deploy av siten
•Körs hos och av driftsleverantören
![Page 13: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/13.jpg)
![Page 14: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/14.jpg)
Att göra en deploy
• .NET Site
•Visual studios ’publish’-funktion (Method: File system)
•Komprimera innehållet till en .zip-fil
• Flytta .zip-filen till samma plats som deploy-scriptet
•Kör scriptet
![Page 15: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/15.jpg)
Hitta siten och stoppa den
![Page 16: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/16.jpg)
Hitta siten och stoppa den
$website = Read-Host "Specify the name of the website"if((Test-Path "IIS:\Sites\$website") -and (Test-Path (Get-WebSite -name $website).physicalPath)){
$filePath = (Get-WebSite -name $website).physicalPath
Stop-WebSite $website
DeploySite $filePath
Start-WebSite $website
}
else {
Write-Host "The website does not exist (check that the spelling is correct)"
}
}
![Page 17: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/17.jpg)
Hitta siten och stoppa den
$website = Read-Host "Specify the name of the website"if((Test-Path "IIS:\Sites\$website")
-and (Test-Path (Get-WebSite -name $website).physicalPath)){}else {
Write-Host "The website does not exist"} $filePath = (Get-WebSite -name $website).physicalPath
Stop-WebSite $website
DeploySite $filePath
Start-WebSite $website
}
![Page 18: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/18.jpg)
Hitta siten och stoppa den
$website = Read-Host "Specify the name of the website"if((Test-Path "IIS:\Sites\$website")
-and (Test-Path (Get-WebSite -name $website).physicalPath)){}else {
Write-Host "The website does not exist"} $filePath = (Get-WebSite -name $website).physicalPath
Stop-WebSite $website
DeploySite $filePath
Start-WebSite $website
}
![Page 19: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/19.jpg)
Hitta siten och stoppa den
$website = Read-Host "Specify the name of the website"if((Test-Path "IIS:\Sites\$website")
-and (Test-Path (Get-WebSite -name $website).physicalPath)){}else {
Write-Host "The website does not exist"} $filePath = (Get-WebSite -name $website).physicalPath
Stop-WebSite $website
DeploySite $filePath
Start-WebSite $website
}
![Page 20: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/20.jpg)
Hitta siten och stoppa den
function SetUp(){
$website = Read-Host "Specify the name of the website"
if((Test-Path "IIS:\Sites\$website")
-and (Test-Path (Get-WebSite -name $website).physicalPath)){
$filePath = (Get-WebSite -name $website).physicalPath
}
}
![Page 21: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/21.jpg)
Hitta siten och stoppa den
if(…){
$filePath = (Get-WebSite -name $website).physicalPath
Stop-WebSite $website
DeploySite $filePath
Start-WebSite $website
}
![Page 22: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/22.jpg)
Hitta siten och stoppa den
if(…){
$filePath = (Get-WebSite -name $website).physicalPath
Stop-WebSite $website
DeploySite $filePath
Start-WebSite $website
}
![Page 23: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/23.jpg)
Gör en deploy av paketet
function DeploySite($filePath){
BackUpSite $filePath
DeleteFolder $filePath
UnZip $filePath
CreateStatusFile $filePath
}
![Page 24: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/24.jpg)
Gör en deploy av paketet
function DeploySite($filePath){
BackUpSite $filePath
DeleteFolder $filePath
UnZip $filePath
CreateStatusFile $filePath
}
![Page 25: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/25.jpg)
Gör en deploy av paketet
function DeploySite($filePath){
BackUpSite $filePath
DeleteFolder $filePath
UnZip $filePath
CreateStatusFile $filePath
}
![Page 26: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/26.jpg)
Gör en deploy av paketet
function DeploySite($filePath){
BackUpSite $filePath
DeleteFolder $filePath
UnZip $filePath
CreateStatusFile $filePath
}
![Page 27: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/27.jpg)
Gör en deploy av paketet
function DeploySite($filePath){
BackUpSite $filePath
DeleteFolder $filePath
UnZip $filePath
CreateStatusFile $filePath
}
![Page 28: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/28.jpg)
Gör en backup av siten
![Page 29: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/29.jpg)
Gör en backup av sitenfunction BackUpSite($filePath){
$backupLocation = "$(get-location)\Backup\Site-backup"
[string]$pathToZipExe = "$(get-location)\7-Zip\7z.exe";
[Array]$arguments = "A", "-tzip", "$backupLocation.zip", $filePath;
& $pathToZipExe $arguments;
Move-Item $filePath\Logs $(get-location)
}
![Page 30: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/30.jpg)
Gör en backup av sitenfunction BackUpSite($filePath){
$backupLocation = "$(get-location)\Backup\Site-backup"
[string]$pathToZipExe = "$(get-location)\7-Zip\7z.exe";
[Array]$arguments = "A", "-tzip", "$backupLocation.zip", $filePath;
& $pathToZipExe $arguments;
Move-Item $filePath\Logs $(get-location)
}
![Page 31: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/31.jpg)
Gör en backup av sitenfunction BackUpSite($filePath){
$backupLocation = "$(get-location)\Backup\Site-backup"
[string]$pathToZipExe = "$(get-location)\7-Zip\7z.exe";
[Array]$arguments = "A", "-tzip", "$backupLocation.zip", $filePath;
& $pathToZipExe $arguments;
Move-Item $filePath\Logs $(get-location)
}
![Page 32: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/32.jpg)
Gör en backup av sitenfunction BackUpSite($filePath){
$backupLocation = "$(get-location)\Backup\Site-backup"
[string]$pathToZipExe = "$(get-location)\7-Zip\7z.exe";
[Array]$arguments = "A", "-tzip", "$backupLocation.zip", $filePath;
& $pathToZipExe $arguments;
Move-Item $filePath\Logs $(get-location)
}
![Page 33: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/33.jpg)
Gör en backup av siten
function BackUpSite($filePath){
$backupLocation = "$(get-location)\Backup\Site-backup"
[string]$pathToZipExe = "$(get-location)\7-Zip\7z.exe";
[Array]$arguments = "A", "-tzip", "$backupLocation.zip", $filePath;
& $pathToZipExe $arguments; ath\Logs $(get-location)
}
![Page 34: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/34.jpg)
Gör en backup av siten
function BackUpSite($filePath){
$backupLocation = "$(get-location)\Backup\Site-backup"
[string]$pathToZipExe = "$(get-location)\7-Zip\7z.exe";
[Array]$arguments = "A", "-tzip", "$backupLocation.zip", $filePath;
& $pathToZipExe $arguments; $filePath\Logs $(get-location)
}
![Page 35: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/35.jpg)
Ta bort den gamla sitenfunction DeleteFolder($filePath){
Remove-Item "$filePath\*" -Force -Recurse
}
![Page 36: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/36.jpg)
Ta bort den gamla siten
function DeleteFolder($filePath){
Remove-Item "$filePath\*" -Force -Recurse
}
![Page 37: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/37.jpg)
Ta bort den gamla siten
function DeleteFolder($filePath){
Remove-Item "$filePath\*" -Force -Recurse
}
![Page 38: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/38.jpg)
Ta bort den gamla siten
function DeleteFolder($filePath){
Remove-Item "$filePath\*" -Force -Recurse
}
![Page 39: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/39.jpg)
Deploy av den nya siten
![Page 40: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/40.jpg)
Deploy av den nya siten
function UnZip($destination){
$shell = new-object -com shell.application
$zip = $shell.NameSpace("$(get-location)\deploy.zip")
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
![Page 41: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/41.jpg)
Deploy av den nya siten
function UnZip($destination){
$shell = new-object -com shell.application
$zip = $shell.NameSpace("$(get-location)\deploy.zip")
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
![Page 42: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/42.jpg)
Deploy av den nya siten
function UnZip($destination){
$shell = new-object -com shell.application
$zip = $shell.NameSpace("$(get-location)\deploy.zip")
foreach($item in $zip.items())
{
$shell.Namespace($destination).copyhere($item)
}
}
![Page 43: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/43.jpg)
![Page 44: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/44.jpg)
Tidsstämpel på deployfunction CreateStatusFile($filePath){
New-Item $filePath\status.html -type file -force -value (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
}
![Page 45: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/45.jpg)
Tidsstämpel på deploy
function CreateStatusFile($filePath){
New-Item $filePath\status.html -type file -force
-value (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
}
![Page 46: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/46.jpg)
Tidsstämpel på deploy
function CreateStatusFile($filePath){
New-Item $filePath\status.html -type file -force
-value (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
}
![Page 47: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/47.jpg)
Tidsstämpel på deploy
function CreateStatusFile($filePath){
New-Item $filePath\status.html -type file -force
-value (Get-Date -Format "yyyy-MM-dd HH:mm:ss")
}
![Page 48: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/48.jpg)
Demo
![Page 49: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/49.jpg)
![Page 50: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/50.jpg)
Varför underlättar scriptet?
![Page 51: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/51.jpg)
Varför underlättar scriptet?
• Tidsinsparning
![Page 52: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/52.jpg)
Varför underlättar scriptet?
• Tidsinsparning
•Garantera att deployen sker på samma sätt varje gång
![Page 53: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/53.jpg)
Varför underlättar scriptet?
• Tidsinsparning
•Garantera att deployen sker på samma sätt varje gång
• Större kontroll över att få deployen som det var tänkt
![Page 54: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/54.jpg)
Varför underlättar scriptet?
• Tidsinsparning
•Garantera att deployen sker på samma sätt varje gång
• Större kontroll över att få deployen som det var tänkt
•Minimera problem och konflikter
![Page 55: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/55.jpg)
Varför underlättar scriptet?
• Tidsinsparning
•Garantera att deployen sker på samma sätt varje gång
• Större kontroll över att få deployen som det var tänkt
•Minimera problem och konflikter
•Hur gör ni med era deployer på externa servrar?
![Page 56: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/56.jpg)
Deploy-paket
![Page 57: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/57.jpg)
Deploy-paket Deploy-script
+
![Page 58: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/58.jpg)
Deploy-paket Deploy-script
+Uppdaterad site
=
![Page 59: Autodeploy när man inte kommer åt miljöerna](https://reader033.vdocuments.site/reader033/viewer/2022051513/54579637af7959795d8b5080/html5/thumbnails/59.jpg)
Tack för att ni lyssnade