ict.ken.be

Delivering solid user friendly software solutions since the dawn of time.

Azure Websites 

Categories: Azure Notes

Notes from Windows Azure Websites by Matt Milner

  • Application load balancer
  • Content + configuration in shared storage
  • http://<account>.azurewebsites.net

Publishing

  • FTP, Web Deploy, Continues integration
  • Use EnableCodeMigrations to create the db and seed some default data
  • Use a publishing profile (import on web publish)
  • One ftp location even though you have multiple instances.

Pricing Models

  • Free only up to 10 sites, multi-tenant, limited dns entries, outbound data limits, throttles on cpu and memory usage.
  • Shared is multi-tenant, per site/instance charges, custom domain names, unlimited outbound charged separately.
  • Reserved is vm-size with 1-3 instances, up to 100 sites.

Monitoring
Counters: CPU, Data in/out, Http Errors, Requests
Diagnostics: Error pages, Logging, IIS logs, Failed request

Team Foundation Service
Setup publishing: Authorize and create build definition
Build: Publish to azure on succesful build

Local Git Repository
Setup publishing: Create repository on azure websites
Push: Push to git repository initiates build on azure
Build: Deploy to azure on succesful build

Solution

  • Make sure your dlls are correctly referenced (use nuget)
  • Correct your Web.Release.config (use preview transformation)
  • .gitignore (packages/ bin/ obj/ *.suo *.csproj.user)

Azure

  • Setup Git Publishing
  • git remote add fooazurealias https://<account>/foo.git
  • git push fooazurealias master

Hosted Git Repository
Codeplex, GitHub, BitBucket
Setup publishing: Create repo on azure, authenticate hosted with oauth
Push: Push to hosted, will post notification to azure, azure will clone repo
Link your Azure website to a specific branch on github.com

Windows Azure PowerShell

get-module

get-command -module azure

$mgmtCert = get-item cert:\\currentuser\my\$mgmtCertThumbprint

Set-AzureSubscription -SubscriptionName KensCloud -SubscriptionId $subscriptionID -Certificate $mgmtCert

Select-AzureSubscription -SubscriptionName KensCloud

get-azurewebsite

get-azurelocation

New-AzureWebsite -Location "West US" -Name "fooNew"

$site = get-azurewebsite -Name fooNew

$site

$site.HttpLoggingEnabled = $true

$site.RequestTracingEnabled = $true

$site.NumberOfWorkers = 3

$site | Set-AzureWebsite

Node.js

npm install azure-cli

node azure account download

node azure account import c:\foo\foo.cer

del c:\foo\KensCloud-11-11-2011-credentials.publishsettings

node azure site create KensNode

node azure site browse KensNode

Azure Cloud & Storage Services 

Categories: Azure Notes

Some notes from Windows Azure Fundamentals by http://mattmilner.com

Fabric controller will keep the requested number of instances running.

Package & Configuration files

  • .cscfg is xml stating the os
  • .cspkg is just a zip file

Service Definition

  • Virtual machine sizing
  • Endpoints
  • Certificates
  • Websites (web role)
  • Environment variables
  • Startup tasks
  • Configuration settings declarations

Service configuration

  • Operation System
  • Instance count
  • Values for configuration settings
  • Certificate thumbprint

Managing Cloud Services

  • Affinity groups
  • Fault domains
  • Upgrade domains
  • VIP swap
  • REST API

Storage Services

  • x509 certificate and SSL
  • Storage Account Keys
  • ETags
  • Azure Storage Explorer

Tables

  • PartitionKey, RowKey, Entity (key/value pairs), Timestamp
  • Max 255 fields including keys
  • Matching partition keys = data in same physical partition
  • Transactions only on the same partition

Blobs/CDN

  • Root container - Named container (first dir) - Blob (second dir and filename) 
  • http://<account>.blob.core.windows.net/images/web/background.jpg
  • Block blobs vs Page blobs
  • Content-cache metadata=TTL in CDN

Queues (max. 7 days)

  • No capitals in name allowed
  • 64kb Max after base64 encoded and including xml headers
  • eg. worker role that creates thumbnails or processes video
  • A worker role can update a message.

GETDATE vs SYSDATETIME 

Categories: SQL Server

The precision of SYSDATETIME is in nanoseconds, the one for GETDATE is in miliseconds.

Just try for yourself

SELECT SYSDATETIME() fn_SysDateTime, GETDATE() fn_GetDate

SQL Insert Or Update AKA Upsert 

Categories: SQL Server

Since MsSQL 2008 you can use the MERGE command for inserting or updating, here is a small example I use with mojoPortal. I call it from a custom PageInitEventHandler and allows me to track what pages a user visits.

CREATE PROCEDURE [dbo].[kenTracking_Pages_Upsert]

@UserGuid	uniqueidentifier,
@SiteGuid	uniqueidentifier,
@PageGuid	uniqueidentifier

AS

SET NOCOUNT, XACT_ABORT ON;

MERGE [dbo].[kenTracking_Pages] WITH (HOLDLOCK) AS target
USING (SELECT @UserGuid, @SiteGuid, @PageGuid) AS source (User_Guid, Site_Guid, Page_Guid)
ON (target.User_Guid = source.User_Guid) AND (target.Site_Guid = source.Site_Guid) AND (target.Page_Guid = source.Page_Guid)
WHEN MATCHED THEN
UPDATE SET Visits = Visits + 1, DateModified = GETDATE()
WHEN NOT MATCHED THEN
INSERT
(
User_Guid,
Site_Guid,
Page_Guid
)
VALUES
(
@UserGuid,
@SiteGuid,
@PageGuid
);

RETURN @@ERROR;
GO
Page 20 of 42 << < 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 40 > >>