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 SetupEpiEnvironment.ps1
$webappname = "myepienvironment" # Application name (lowercase alphanumeric only)
$subscriptionname = "My subscription name"
$resourcegroupname ="$webappname-ResourceGroup"
$location="West Europe"
$sqladminlogin = "SaUser"
$sqlpassword = "YourSecretAdminPassword1"
$startip = "111.112.113.114"
$endip = "111.112.113.114"
$storageaccountname = "$($webappname)media"
View DeployFromSourceStep2.ps1
# DXC-S deploy from source environment to target environment. Step two, finish the deploy by swapping slots.
if (-not (Get-Module -Name EpiCloud -ListAvailable)) {
Install-Module EpiCloud -Scope CurrentUser -Force
Write-Host "Installed EpiCloud module."
}
Connect-EpiCloud -ClientKey $OctopusParameters["DXC-S API Key"] -ClientSecret $OctopusParameters["DXC-S API Secret"]
# Find a deployment that has the status "AwaitingVerification".
View DeployFromSourceStep1.ps1
# DXC-S deploy from source environment to target environment. Step one that deploys to a slot on target.
# Install the EpiCloud module
if (-not (Get-Module -Name EpiCloud -ListAvailable)) {
Install-Module EpiCloud -Scope CurrentUser -Force
Write-Output "Installed EpiCloud module"
}
Connect-EpiCloud -ClientKey $OctopusParameters["DXC-S API Key"] -ClientSecret $OctopusParameters["DXC-S API Secret"]
View DefaultPageController.cs
namespace AlloyDemo.Controllers
{
[TemplateDescriptor(Inherited = true)]
public class DefaultPageController : PageControllerBase<SitePageData>
{
[EditableContentOutputCache]
public ViewResult Index(SitePageData currentPage)
{
var model = CreateModel(currentPage);
return View($"~/Views/{currentPage.GetOriginalType().Name}/Index.cshtml", model);
View SitePageData.cs
namespace AlloyDemo.Models.Pages
{
public abstract class SitePageData : PageData, ICustomCssInContentArea, IDisableOutputCache
{
[Display(Name = "Disable output cache", GroupName = SystemTabNames.Settings, Order = 500)]
public virtual bool? DisableOutputCache { get; set; }
...
View EditableContentOutputCacheAttribute.cs
namespace AlloyDemo.Business
{
public sealed class EditableContentOutputCacheAttribute : ContentOutputCacheAttribute
{
public EditableContentOutputCacheAttribute()
{
UseOutputCacheValidator = UseOutputCache;
}
private static bool UseOutputCache(IPrincipal principal, HttpContextBase context, TimeSpan duration)
View IDisableOutputCache.cs
namespace AlloyDemo.Business
{
public interface IDisableOutputCache
{
bool? DisableOutputCache { get; set; }
}
}
@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
@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 `
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,
You can’t perform that action at this time.