Here is a simple PowerShell script to change your azure instance type in .csdef file. You need to run this from your code repository and enter the instance type ie "small", ExtraSmall","Medium" etc when prompted
$allCsDefFiles = Get-ChildItem -Recurse -filter *.csdef | ForEach-Object -Process {$_.FullName}
$newvmsize = Read-Host 'Enter the instance type'
foreach ($thisCsDefFile in $allCsDefFiles)
{
[xml]$thisCsDefXml = Get-Content $thisCsDefFile
$root = $thisCsDefXml.get_DocumentElement();
If (!$root.WebRole.vmsize)
{ Write-Host "No webrole found in $($root.name) "
}
else
{
$root.WebRole.vmsize = $newvmsize
$thisCsDefXml.Save($thisCsDefFile)
Write-host "Webrole size of $($root.name) changed to $($root.WebRole.vmsize)"
}
If (!$root.Workerrole.vmsize)
{ Write-Host "No Workerrole found in $($root.name) "
}
else
{
$root.Workerrole.vmsize = $newvmsize
$thisCsDefXml.Save($thisCsDefFile)
Write-host "Workerrole size of $($root.name) changed to $($root.Workerrole.vmsize)"
}
}
$allCsDefFiles = Get-ChildItem -Recurse -filter *.csdef | ForEach-Object -Process {$_.FullName}
$newvmsize = Read-Host 'Enter the instance type'
foreach ($thisCsDefFile in $allCsDefFiles)
{
[xml]$thisCsDefXml = Get-Content $thisCsDefFile
$root = $thisCsDefXml.get_DocumentElement();
If (!$root.WebRole.vmsize)
{ Write-Host "No webrole found in $($root.name) "
}
else
{
$root.WebRole.vmsize = $newvmsize
$thisCsDefXml.Save($thisCsDefFile)
Write-host "Webrole size of $($root.name) changed to $($root.WebRole.vmsize)"
}
If (!$root.Workerrole.vmsize)
{ Write-Host "No Workerrole found in $($root.name) "
}
else
{
$root.Workerrole.vmsize = $newvmsize
$thisCsDefXml.Save($thisCsDefFile)
Write-host "Workerrole size of $($root.name) changed to $($root.Workerrole.vmsize)"
}
}
This comment has been removed by a blog administrator.
ReplyDelete