This file contains 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
$connectionName = "AzureRunAsConnection" | |
try | |
{ | |
# Get the connection "AzureRunAsConnection " | |
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName | |
"Logging in to Azure..." | |
Add-AzureRmAccount ` | |
-ServicePrincipal ` | |
-TenantId $servicePrincipalConnection.TenantId ` |
This file contains 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
using ImageProcessor.Web.Episerver; | |
namespace PictureDemo.Business.Rendering | |
{ | |
public static class ImageTypes | |
{ | |
// A full width Hero image is very simple, since its always 100% of the viewport width. | |
public static ImageType HeroImage = new ImageType | |
{ | |
DefaultImgWidth = 1280, |
This file contains 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
using MyEpiSite.Business.Rendering; | |
using System; | |
using System.Configuration; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace MyEpiSite.Helpers | |
{ | |
public static class PictureHelper | |
{ |
This file contains 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
namespace MyEpiSite.Business.Rendering | |
{ | |
public class ImageType | |
{ | |
public int? DefaultImgWidth { get; set; } //this size will be used in browsers that don't support the picture element | |
public int[] SrcSetWidths { get; set; } // the different image widths you want the browser to select from | |
public string[] SrcSetSizes { get; set; } | |
public double HeightRatio { get; set; } | |
public int Quality { get; set; } |
This file contains 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
namespace MyEpiSite.Business.Rendering | |
{ | |
public class ImageType | |
{ | |
public int? DefaultImgWidth { get; set; } //this size will be used in browsers that don't support the picture element | |
public int[] SrcSetWidths { get; set; } // the different image widths you want the browser to select from | |
public string[] SrcSetSizes { get; set; } | |
} | |
public static class ImageTypes |
This file contains 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
using MyEpiSite.Business.Rendering; | |
using System.Configuration; | |
using System.Web; | |
using System.Web.Mvc; | |
namespace MyEpiSite.Helpers | |
{ | |
public static class PictureHelper | |
{ | |
public static IHtmlString Picture(this HtmlHelper helper, string imageUrl, ImageType imageType, string cssClass = "") |
This file contains 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
using System; | |
using System.Collections.Generic; | |
using System.Configuration; | |
using System.Globalization; | |
using System.Linq; | |
using EPiServer.Framework; | |
using EPiServer.Framework.Initialization; | |
using EPiServer.ServiceLocation; | |
using EPiServer.Web; |
This file contains 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
function NotifySlack($webhookurl, $channel, $message) | |
{ | |
$payload = @{ | |
"channel" = $channel | |
"icon_emoji" = ":robot_face:" | |
"text" = $message | |
"username" = "Mr. Robot" | |
} | |
Invoke-WebRequest -UseBasicParsing -Body (ConvertTo-Json -Compress -InputObject $payload) -Method Post -Uri $webhookurl | Out-Null | |
} |
This file contains 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
Import-Module "D:\home\site\wwwroot\ScaleDownDevEnvironments\LoginToAzure.ps1" | |
Import-Module "D:\home\site\wwwroot\ScaleDownDevEnvironments\NotifySlack.ps1" | |
Login | |
#scale down web app to "D1 Shared" | |
Set-AzureRmAppServicePlan -Name "<your sesrvice plan name>" -ResourceGroupName "<your resource group name>" -Tier Shared | |
#scale down database to "B1 Basic" | |
Set-AzureRmSqlDatabase -ResourceGroupName "<your resource group name>" -ServerName "<sql server name>" -DatabaseName "<database name>" -Edition Basic |
This file contains 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
function Login() { | |
$azureappid ="45d6472e-0526-4a12-8c58-959f697eb296" #your Azure application id | |
$azurepassword = ConvertTo-SecureString "YourSecretPassword" -AsPlainText -Force | |
$pscred = New-Object System.Management.Automation.PSCredential($azureappid, $azurepassword) | |
Login-AzureRmAccount -Credential $pscred -ServicePrincipal -TenantId "31d2b6c6-a122-456c-b9a5-af2d7e3fbf0f" #you Azure subscription Tenant id | |
} |