简体   繁体   中英

Azure Server Farm Not Found

I am trying to create an azure website via a powershell script. The hosting plan has already been create, I simply wish to add a new website to it.

The script I'm using is this:

Switch-AzureMode AzureResourceManager

$targetServicePlan = Get-AzureResource -Name my-serviceplan -OutputObjectFormat New

New-AzureResource -Name MyTestSite -Location "West Europe" `
    -ResourceGroupName Default-Web-WestEurope `
    -ResourceType 'Microsoft.Web/sites' `
    -PropertyObject @{"name" = "MyTestSite"; "ServerFarmId" = $targetServicePlan.ResourceId } `
    -OutputObjectFormat New

The server farm ($targetServicePlan) has a resource id, so I'm assuming that it exists (there is also a hosting plan in the azure portal with this name). Yet when I try to create the website I get the error: "Server farm with name my-serviceplan not found."

The full error is:

New-AzureResource : {"Code":"NotFound","Message":"Server farm with name my-serviceplan not found.","Target":null,"Details":[{"Message":"Server farm with name
my-serviceplan not found."},{"Code":"NotFound"},{"ErrorEntity":{"Code":"NotFound","Message":"Server farm with name my-serviceplan not
found.","ExtendedCode":"11001","MessageTemplate":"Server farm with name {0} not found.","Parameters":["my-serviceplan"],"InnerErrors":null}}],"Innererror":null}
At line:1 char:1
+ New-AzureResource -Name MyTestSite -Location "West Europe" -ResourceGrou ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureResource], ErrorResponseMessageException
+ FullyQualifiedErrorId : NotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceCmdlet

What am I missing?

Is your $targetServicePlan in 'West Europe'? If not that could be the reason for that not-so-helpful error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM