I'm trying to create an Azure Function via PowerShell.
First I successfully did it with Basic plan
$azFunctionAppServiceObject = @{
location = $iothubLocation
sku = @{
name = "B1"
tier = "Basic"
}
kind = "functionapp"
properties = @{
reserved = "false"
kind = "functionapp"
}
}
$appServicePlan = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceType "Microsoft.Web/serverfarms" -Name $appServicePlanName -ErrorAction SilentlyContinue
if (!$appServicePlan)
{
$appServicePlan = New-AzResource -ResourceGroupName $resourceGroupName -ResourceType "Microsoft.Web/serverfarms" -Name $appServicePlanName -IsFullObject -PropertyObject $azFunctionAppServiceObject -Force
}
$storageAccount = Get-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $blobStorageAccountName -ErrorAction SilentlyContinue
if (!$storageAccount)
{
Write-Output ">----------- Creating storage account"
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroupName -Name $blobStorageAccountName -SkuName Standard_LRS -Location $iothubLocation -Kind StorageV2 -AccessTier Hot
}
$trigger = Get-AzFunctionApp -ResourceGroupName $resourceGroupName `
-Name $FunctionAppName `
if (!$trigger)
{
Write-Output ">----------- Creating trigger"
New-AzFunctionApp -ResourceGroupName $resourceGroupName `
-Name $FunctionAppName `
-PlanName $appServicePlanName `
-StorageAccount $blobStorageAccountName `
-Runtime Dotnet `
-FunctionsVersion 4 `
-RuntimeVersion 6 `
-OSType Windows
}
But If I change the configuration object to this:
$azFunctionAppServiceObject = @{
location = $iothubLocation
sku = @{
name = "Y1"
tier = "Dynamic"
}
kind = "functionapp"
properties = @{
reserved = "false"
kind = "functionapp"
}
}
I get
Az.Functions.internal\New-AzFunctionApp : The server responded with a Request Error, Status: Conflict At C:\Program Files\WindowsPowerShell\Modules\Az.Functions\4.0.1\custom\New-AzFunctionApp.ps1:528 char:17
+ ... Az.Functions.internal\New-AzFunctionApp @PSBoundParameter ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ ResourceGroup...20190801.Site }:<>f__AnonymousType0`4) [New-AzFunctionApp_Create], RestException`1
+ FullyQualifiedErrorId : Conflict,Microsoft.Azure.PowerShell.Cmdlets.Functions.Cmdlets.NewAzFunctionApp_Create