0
votes

I'm busy writing some deployment scripts. One of the things this script needs to do is publish a new Azure Website. To do so, I've already written some lines which create a new Website in Azure. Afterwards, my website has to be deployed. Reading up on this matter it appears this can be done using msbuild and the DeployOnBuild parameter.

So far the script looks like a bit like this (simplified):

New-AzureResourceGroup -Location $locationWestEUDataCenter -Name $resourceGroupNameEU
New-AzureResource -ApiVersion 2014-04-01 -Name $hostingPlanNameEU -ResourceGroupName $resourceGroupNameEU `
                        -ResourceType Microsoft.Web/serverFarms -Location $locationWestEUDataCenter `
                        -PropertyObject $hostingPlanParametersEU -Verbose -Force
$siteWestEUProperties = @{name = $siteNameEU; sku = "Basic"; webHostingPlan = $hostingPlanNameEU}
New-AzureResource  -Name $siteNameEU -ResourceType Microsoft.Web/sites `
                         -ResourceGroupName $resourceGroupNameEU -Location $locationWestEUDataCenter `
                         -ApiVersion $apiVersion -PropertyObject $siteWestEUProperties
Switch-AzureMode AzureServiceManagement

The MSBuild publish looks like this at the moment (copy of http://www.asp.net/aspnet/overview/developing-apps-with-windows-azure/building-real-world-cloud-apps-with-windows-azure/automate-everything):

& "$env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" $websiteProjectFileAnalytics `
    /p:VisualStudioVersion=11.0 `
    /p:DeployOnBuild=true `
    /p:PublishProfile=$publishingFileAnalytics `
    /p:Password=$publishSettings.publishData.publishProfile.userPWD.get(0)

The problem I'm having with this line of code is the Password property. The password has to be retrieved from a PublishSettings file. This passwork isn't present on the subscription PublishSettings file. This password (and a lot of other properties) is present in the PublishSettings file which you can download from the website management page in the Azure portal.

See my problem here?

I want a fully automated deployment of the complete software suite. Is there a way I can set the password of the specific websites I'm creating? If this is possible, I can manage the password in PowerShell and use the password while publishing.

Or is there a different/better way to automate the deployments of Azure Websites?

On a sidenote: I'm a PowerShell newbie, but already succeeded in automatically deploying Cloud Services, Service Busses, database, Traffic Manager, Storage.

1

1 Answers

1
votes

It's always the same, after asking a question you read something which might be the solution of your problem.

In a blog post of Kaushal Kumar Panday was reading the following:

Now lets click on the option “Reset your deployment credentials”. This will prompt the user with the following pop-up:

image

Now, this option is self explanatory. It allows the user to change the deployment credentials i.e., the username and password. However this option is not specific to a website, as the user is changing the password for the deployment account, it will affect all the web sites. These credentials are directly tied to the Microsoft account (Outlook.com or Live.com). So changing these credentials will be changing it for all the subscriptions tied to the Microsoft account.

This means I can change the deployment credentials once, for the subscription, and use these credentials in my script. Doing so results in the following command:

& "$env:windir\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe" $websiteProjectFileAnalytics `
    /p:VisualStudioVersion=12.0 `
    /p:DeployOnBuild=true `
    /p:PublishProfile=$publishingFileAnalytics `
    /p:Password=$azureDeploymentPassword `
    /p:UserName=$azureDeploymentUsername `
    /p:MSDeployServiceURL=mywebsite.scm.azurewebsites.net:443

For this to work, you do need to remove the UserName and MSDeployServiceURL elements from your pubxml file. I also removed the _SavePWD element as it doesn't do anything anymore (I guess).

My website is now successfully deployed to Azure.