emp*_*emp 5 cmdlets azure-web-sites azure-powershell
我一直在阅读以下文章,该文章介绍了如何更改您网站的网络托管计划.
这似乎工作正常,但如果我使用相同的命令来更改Web托管模式(使用property:"sku": "Free"to "sku": "Standard")它不会给出任何错误反馈,只返回未更改的(上一个)存储配置.
执行命令:
$standardServer=@{"sku" = "Standard"; }
Set-AzureResource -Name 'tmtest2' -ResourceGroupName 'Default-Web-JapanWest' -ResourceType Microsoft.Web/sites -ApiVersion 2014-04-01 -PropertyObject $standardServer
Run Code Online (Sandbox Code Playgroud)
任何人都有运气改变使用Powershell的网络托管模式?
编辑:我也试过这个链接,准确描述了我想要实现的目标.但它没有用.
emp*_*emp 11
我想通了.您需要首先创建一个托管计划(使用"标准"模式)作为默认资源组下的资源.然后,您需要将网站分配给hostingplan.
这是完整的脚本:
Switch-AzureMode AzureResourceManager
Add-AzureAccount
$locations = @('East Asia', 'Southeast Asia', 'East US', 'East US 2', 'West US', 'North Central US', 'South Central US', 'Central US', 'North Europe', 'West Europe', 'Japan East', 'Japan West', 'Brazil South')
$websiteName = Read-Host 'What is the name of your website (without azurewebsites.net)' #tmtest2
$location = Read-Host 'What is the region location of the website'
if (-Not($locations -contains $location)) {
throw "location is incorrect, try one of these values: " + (($locations | select -expand $_) -join ", ")
}
$resourceGroupName = 'Default-Web-' + $location.Replace(' ', '');
#create a new web hosting plan - Small Standard machine
$hostingPlanName = $websiteName + 'HostingPlan';
$p=@{"name"= $hostingPlanName;"sku"= "Standard";"workerSize"= "0";"numberOfWorkers"= 1}
New-AzureResource -ApiVersion 2014-04-01 -Name $hostingPlanName -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/serverFarms -Location $location -PropertyObject $p -Verbose -Force
$r = Get-AzureResource -Name $websiteName -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites -ApiVersion 2014-04-01
echo $r
$p = $null;
$p = @{ 'serverFarm' = $hostingPlanName }
$r = Set-AzureResource -Name $websiteName -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites -ApiVersion 2014-04-01 -PropertyObject $p
#echo $r.Properties
if (-Not($r.Properties['sku'] -eq 'Standard')) {
throw 'script executed but sku has not been changed'
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4229 次 |
| 最近记录: |