Last active
August 4, 2021 08:21
-
-
Save russmckendrick/0555f4f39e38ff7e2e6a3ee43e91a884 to your computer and use it in GitHub Desktop.
configure-music-app.ps1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<# | |
.SYNOPSIS | |
Downloads and configures .Net Core Music Store application sample across IIS and Azure SQL DB. | |
#> | |
Param ( | |
[string]$user, | |
[string]$password, | |
[string]$sqlserver, | |
[string]$database | |
) | |
# Force use of TLS 1.2 | |
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 | |
# Firewall | |
netsh advfirewall firewall add rule name="http" dir=in action=allow protocol=TCP localport=80 | |
# Folders | |
New-Item -ItemType Directory c:\temp | |
New-Item -ItemType Directory c:\music | |
# Install iis | |
Install-WindowsFeature web-server -IncludeManagementTools | |
# Install dot.net core sdk | |
Invoke-WebRequest http://go.microsoft.com/fwlink/?LinkID=615460 -outfile c:\temp\vc_redistx64.exe | |
Start-Process c:\temp\vc_redistx64.exe -ArgumentList '/quiet' -Wait | |
Invoke-WebRequest https://go.microsoft.com/fwlink/?LinkID=809122 -outfile c:\temp\DotNetCore.1.0.0-SDK.Preview2-x64.exe | |
Start-Process c:\temp\DotNetCore.1.0.0-SDK.Preview2-x64.exe -ArgumentList '/quiet' -Wait | |
Invoke-WebRequest https://go.microsoft.com/fwlink/?LinkId=817246 -outfile c:\temp\DotNetCore.WindowsHosting.exe | |
Start-Process c:\temp\DotNetCore.WindowsHosting.exe -ArgumentList '/quiet' -Wait | |
# Download music app | |
Invoke-WebRequest https://github.com/Microsoft/dotnet-core-sample-templates/raw/master/dotnet-core-music-windows/music-app/music-store-azure-demo-pub.zip -OutFile c:\temp\musicstore.zip | |
Expand-Archive C:\temp\musicstore.zip c:\music | |
# Azure SQL connection sting in environment variable | |
[Environment]::SetEnvironmentVariable("Data:DefaultConnection:ConnectionString", "Server=$sqlserver;Database=$database;Integrated Security=False;User Id=$user;Password=$password;MultipleActiveResultSets=True;Connect Timeout=30",[EnvironmentVariableTarget]::Machine) | |
# Pre-create database | |
$env:Data:DefaultConnection:ConnectionString = "Server=$sqlserver;Database=$database;Integrated Security=False;User Id=$user;Password=$password;MultipleActiveResultSets=True;Connect Timeout=30" | |
Start-Process 'C:\Program Files\dotnet\dotnet.exe' -ArgumentList 'c:\music\MusicStore.dll' | |
# Configure iis | |
Remove-WebSite -Name "Default Web Site" | |
Set-ItemProperty IIS:\AppPools\DefaultAppPool\ managedRuntimeVersion "" | |
New-Website -Name "MusicStore" -Port 80 -PhysicalPath C:\music\ -ApplicationPool DefaultAppPool | |
& iisreset |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment