On my recent appearance on Cloud Cover my demo failed
Sad to say but it happens. Especially, when you don’t test your demo after rebuilding your laptop. That’s OK though. The beauty of the Internet is you can always make up for it later by posting a working example
So here it is in it’s entirety a script that deploys a Windows Azure solution to two data centers and configures Traffic Manager to balance traffic between the endpoints.
#Select subscription first select-Subscription azurepub $certpath = 'C:\managementCert.pfx' $mcpwd = 'certPassword!' # Deployment package and configuration $PackageFile = 'C:\Deployment\MortgageApp.cspkg' $ServiceConfig = 'C:\Deployment\ServiceConfiguration.Cloud.cscfg' # Set up our variables for each data center $NCService = 'WoodGroveNC' $EUService = 'WoodGroveEU' $NCStorage = 'demoncstorage1' $EUStorage = 'demoeustorage1' $NCDC = 'North Central US' $EUDC = 'North Europe' $TMProfileName = 'WoodGroveGlobalTM' # Set up our variables for each data center $NCService = 'WoodGroveNC' $EUService = 'WoodGroveEU' $NCStorage = 'demoncstorage1' $EUStorage = 'demoeustorage1' $NCDC = 'North Central US' $EUDC = 'North Europe' $TMProfileName = 'WoodGroveGlobalTM' # Created Hosted Service in North Central US New-HostedService -ServiceName $NCService -Location $NCDC | Get-OperationStatus -WaitToComplete # Created Hosted Service in Europe New-HostedService -ServiceName $EUService -Location $EUDC | Get-OperationStatus -WaitToComplete # Get a reference to the newly created services $hostedServiceNC = Get-HostedService -ServiceName $NCService $hostedServiceEU = Get-HostedService -ServiceName $EUService # Add the management certificate to each hosted service $hostedServiceNC | Add-Certificate -CertToDeploy $certpath -Password $mcpwd | Get-OperationStatus -WaitToComplete $hostedServiceEU | Add-Certificate -CertToDeploy $certpath -Password $mcpwd | Get-OperationStatus -WaitToComplete # Create a new storage account in each data center New-StorageAccount -StorageAccountName $NCStorage -Location $NCDC | Get-OperationStatus -WaitToComplete New-StorageAccount -StorageAccountName $EUStorage -Location $EUDC | Get-OperationStatus -WaitToComplete $hostedServiceEU | New-Deployment -Name $EUService -StorageAccountName $EUStorage ` -Package $PackageFile -Configuration $ServiceConfig | Get-OperationStatus -WaitToComplete # Deploy the hosted service to each data center $hostedServiceNC | New-Deployment -Name $NCService -StorageAccountName $NCStorage ` -Package $PackageFile -Configuration $ServiceConfig | Get-OperationStatus -WaitToComplete # Start each service $hostedServiceNC | Get-Deployment -Slot Production | Set-DeploymentStatus -Status Running ` | Get-OperationStatus -WaitToComplete $hostedServiceEU | Get-Deployment -Slot Production | Set-DeploymentStatus -Status Running ` | Get-OperationStatus -WaitToComplete # Configure Traffic Manager to enable Performance Based Load Balancing and Failover $profile = New-TrafficManagerProfile -ProfileName $TMProfileName ` -DomainName 'woodgroveglobal.trafficmanager.net' $endpoints = @() $endpoints += New-TrafficManagerEndpoint -DomainName 'WoodGroveNC.cloudapp.net' $endpoints += New-TrafficManagerEndpoint -DomainName 'WoodGroveEU.cloudapp.net' # Configure the endpoint Traffic Manager will monitor for service health $monitors = @() $monitors += New-TrafficManagerMonitor –Port 80 –Protocol HTTP –RelativePath / # Create new definition $createdDefinition = New-TrafficManagerDefinition -ProfileName $TMProfileName -TimeToLiveInSeconds 300 ` -LoadBalancingMethod Performance -Monitors $monitors -Endpoints $endpoints -Status Enabled # Enable the profile with the newly created traffic manager definition Set-TrafficManagerProfile -ProfileName $TMProfileName -Enable -DefinitionVersion $createdDefinition.Version
Hmmm.
Hi Michael!
Why do you declare the variables twice?
Line 11-18 and Lines 20 – 27
Oops! Typo
FYI – The Traffic Manager cmdlets have not made it to the official cmdlet tree yet. However, I’ve talked to that team recently and they are reviewing in what time frame they can resurrect them and get them shipped.