Skip to content

Instantly share code, notes, and snippets.

Erik Henningson ErikHen

Block or report user

Report or block ErikHen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View run.ps1
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
@ErikHen
ErikHen / NotifySlack.ps1
Last active Nov 22, 2017
PowerShell function that sends a message to Slack
View NotifySlack.ps1
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
}
View EnvironmentInitialization.cs
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;
View PictureHelper.cs
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 = "")
View ImageTypes.cs
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
View ImageTypes.cs
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; }
View PictureHelper.cs
using MyEpiSite.Business.Rendering;
using System;
using System.Configuration;
using System.Web;
using System.Web.Mvc;
namespace MyEpiSite.Helpers
{
public static class PictureHelper
{
View ImageTypes.cs
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,
@ErikHen
ErikHen / LoginToAzure
Created Apr 3, 2019
Azure Automation Powershell Runbook that logs in to Azure
View LoginToAzure
$connectionName = "AzureRunAsConnection"
try
{
# Get the connection "AzureRunAsConnection "
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName
"Logging in to Azure..."
Add-AzureRmAccount `
-ServicePrincipal `
-TenantId $servicePrincipalConnection.TenantId `
@ErikHen
ErikHen / ScaleDownResources
Created Apr 3, 2019
Azure Automation Powershell Runbook that scales Azure resources
View ScaleDownResources
.\LoginToAzure.ps1
#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
#scale a web app to "B2 Basic"
#Set-AzureRmAppServicePlan -Name "<your sesrvice plan name>" -ResourceGroupName "<your resource group name>" -Tier Basic -WorkerSize Medium
You can’t perform that action at this time.