如何使用 New-AzAppServicePlan 创建 Linux AppService 计划?
How to create a Linux AppService Plan with New-AzAppServicePlan?
此代码使用 New-AzAppServicePlan
的等效项是什么?
az appservice plan create --resource-group $ServerFarmResourceGroupName `
--name $AppServicePlanName `
--is-linux `
--location $ResourceGroupLocation `
--sku $AppServicePlanTier `
--number-of-workers $NumberOfWorkers
真的没有办法使用 Az Powershell 创建应用服务计划吗?为什么只能通过 Azure CLI 或 ARM 来完成?
我只找到这个答案,基本上直接使用ARM:
这方面存在一些问题,假设 New-AzureRmAppServicePlan
目前不支持此功能,但是您可以使用 New-AzureRmResource
创建一个 linux 计划。您可以尝试以下命令。
New-AzureRmResource -ResourceGroupName <>group name -Location "Central US" -ResourceType microsoft.web/serverfarms -ResourceName <plan name> -kind linux -Properties @{reserved="true"} -Sku @{name="S1";tier="Standard"; size="S1"; family="S"; capacity="1"} -Force
我最初使用脚本通过 PowerShell 和 AzureCLI 创建 ConsumptionPlan (Y1),因为我不喜欢 Azure 在创建 ConsumptionPlan 时放置生成的名称。
请找到我使用 New-AzResource 创建 Linux 应用服务计划 (B1) 的解决方案:
$fullObject = @{
location = "West Europe"
sku = @{
name = "B1"
tier = "Basic"
}
kind = "linux"
properties = @{
reserved = $true
}
}
$resourceGroupName = "rg-AppServicePlanLinux"
$serverFarmName = "aspl-test"
Write-Host "Step 1: CREATING APP SERVICE PLAN B1:Basic named [$serverFarmName]"
# Create a server farm which will host the function app in the resource group specified
New-AzResource -ResourceGroupName $resourceGroupName -ResourceType "Microsoft.Web/serverfarms" -Name $serverFarmName -IsFullObject -PropertyObject $fullObject -Force
所以我使用 ARM 模板来了解您需要在 -PropertyObject 参数上提供哪些信息
现在似乎也可以使用 New-AzAppServicePlan 命令执行应用服务计划 Linux 自 Az PowerShell 4.3.0(2020 年 6 月)以来,参数 -Linux
Az.Websites
Added safeguard to delete created webapp if restore failed in 'Restore-AzDeletedWebApp'
Added 'SourceWebApp.Location' for 'New-AzWebApp' and 'New-AzWebAppSlot'
Fixed bug that prevented changing Container settings in 'Set-AzWebApp' and 'Set-AzWebAppSlot'
Fixed bug to get SiteConfig when -Name is not given for Get-AzWebApp
Added a support to create ASP for Linux Apps
Added exceptions for clone across resource groups
新的 AzAppServicePlan:https://docs.microsoft.com/en-us/powershell/module/az.websites/new-azappserviceplan?view=azps-5.6.0
如果使用 Azure CLI 部署新的 Function 应用程序(消费计划)后出现“服务不可用”,请确认 Microsoft 的以下声明:
https://github.com/Azure/Azure-Functions/wiki/Creating-Function-Apps-in-an-existing-Resource-Group
我浪费了一整天,因为我在用于部署消费应用程序的同一资源组中获得了另一个功能应用程序(高级计划)。
这对我有用:
将 -Linux
作为参数添加到我的命令中
New-AzAppServicePlan -ResourceGroupName $RESOURCE_GROUP_NAME -Name $APP_SERVICE_PLAN_NAME -Location $RESOURCE_LOCATION -Linux -Tier $APP_SERVICE_PLAN_TIER -NumberofWorkers $APP_SERVICE_PLAN_WORKERS -WorkerSize $APP_SERVICE_PLAN_WORKER_SIZE
示例:
New-AzAppServicePlan -ResourceGroupName 'MyResourceGroup' -Name 'MyServicePlan' -Location 'northeurope' -Linux -Tier 'PremiumV2' -NumberofWorkers 2 -WorkerSize Medium
就这些了。
希望对您有所帮助
此代码使用 New-AzAppServicePlan
的等效项是什么?
az appservice plan create --resource-group $ServerFarmResourceGroupName `
--name $AppServicePlanName `
--is-linux `
--location $ResourceGroupLocation `
--sku $AppServicePlanTier `
--number-of-workers $NumberOfWorkers
真的没有办法使用 Az Powershell 创建应用服务计划吗?为什么只能通过 Azure CLI 或 ARM 来完成?
我只找到这个答案,基本上直接使用ARM:
这方面存在一些问题,假设 New-AzureRmAppServicePlan
目前不支持此功能,但是您可以使用 New-AzureRmResource
创建一个 linux 计划。您可以尝试以下命令。
New-AzureRmResource -ResourceGroupName <>group name -Location "Central US" -ResourceType microsoft.web/serverfarms -ResourceName <plan name> -kind linux -Properties @{reserved="true"} -Sku @{name="S1";tier="Standard"; size="S1"; family="S"; capacity="1"} -Force
我最初使用脚本通过 PowerShell 和 AzureCLI 创建 ConsumptionPlan (Y1),因为我不喜欢 Azure 在创建 ConsumptionPlan 时放置生成的名称。
请找到我使用 New-AzResource 创建 Linux 应用服务计划 (B1) 的解决方案:
$fullObject = @{
location = "West Europe"
sku = @{
name = "B1"
tier = "Basic"
}
kind = "linux"
properties = @{
reserved = $true
}
}
$resourceGroupName = "rg-AppServicePlanLinux"
$serverFarmName = "aspl-test"
Write-Host "Step 1: CREATING APP SERVICE PLAN B1:Basic named [$serverFarmName]"
# Create a server farm which will host the function app in the resource group specified
New-AzResource -ResourceGroupName $resourceGroupName -ResourceType "Microsoft.Web/serverfarms" -Name $serverFarmName -IsFullObject -PropertyObject $fullObject -Force
所以我使用 ARM 模板来了解您需要在 -PropertyObject 参数上提供哪些信息
现在似乎也可以使用 New-AzAppServicePlan 命令执行应用服务计划 Linux 自 Az PowerShell 4.3.0(2020 年 6 月)以来,参数 -Linux
Az.Websites
Added safeguard to delete created webapp if restore failed in 'Restore-AzDeletedWebApp' Added 'SourceWebApp.Location' for 'New-AzWebApp' and 'New-AzWebAppSlot' Fixed bug that prevented changing Container settings in 'Set-AzWebApp' and 'Set-AzWebAppSlot' Fixed bug to get SiteConfig when -Name is not given for Get-AzWebApp Added a support to create ASP for Linux Apps Added exceptions for clone across resource groups
新的 AzAppServicePlan:https://docs.microsoft.com/en-us/powershell/module/az.websites/new-azappserviceplan?view=azps-5.6.0
如果使用 Azure CLI 部署新的 Function 应用程序(消费计划)后出现“服务不可用”,请确认 Microsoft 的以下声明: https://github.com/Azure/Azure-Functions/wiki/Creating-Function-Apps-in-an-existing-Resource-Group 我浪费了一整天,因为我在用于部署消费应用程序的同一资源组中获得了另一个功能应用程序(高级计划)。
这对我有用:
将 -Linux
作为参数添加到我的命令中
New-AzAppServicePlan -ResourceGroupName $RESOURCE_GROUP_NAME -Name $APP_SERVICE_PLAN_NAME -Location $RESOURCE_LOCATION -Linux -Tier $APP_SERVICE_PLAN_TIER -NumberofWorkers $APP_SERVICE_PLAN_WORKERS -WorkerSize $APP_SERVICE_PLAN_WORKER_SIZE
示例:
New-AzAppServicePlan -ResourceGroupName 'MyResourceGroup' -Name 'MyServicePlan' -Location 'northeurope' -Linux -Tier 'PremiumV2' -NumberofWorkers 2 -WorkerSize Medium
就这些了。
希望对您有所帮助