Azure / Azure/azure-powershell

New-AzFunctionApp returns uninformative error when Linux Azure functions are created in resourceGroups with Windows-based functions

Open
#13,315 4 comments 0 reactions 1 assignee Claimed by @Francisco-Gamino View on GitHub
act-observability-squad Functions
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

## Known problem

As the Azure function documentation explains
[You can't host Linux and Windows apps in the same resource group.](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-first-azure-function-azure-cli?tabs=bash%2Cbrowser&pivots=programming-language-python)

`New-AzFunctionApp` returns an uninformative error message and value when this occurs.

## Steps to reproduce

Run this command

```
New-AzFunctionApp -ResourceGroupName NfvGroupTest -Name MLtmp -Runtime python -RuntimeVersion 3.8 -FunctionsVersion 3 -OSType Linux

```
when there are existing function apps on Windows on "NfvGroupTest"

## Error output

```
Az.Functions.internal\New-AzFunctionApp : The server responded with a Server Error, Status: InternalServerError
At C:\Users\joagosta\Documents\WindowsPowerShell\Modules\Az.Functions\1.0.2\custom\New-AzFunctionApp.ps1:506 char:17
+ ... Az.Functions.internal\New-AzFunctionApp @PSBoundParameter ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: ({ ResourceGroup...20190801.Site }:<>f__AnonymousType0`4) [New-AzFunctionApp_Create], RestException`1
+ FullyQualifiedErrorId : InternalServerError,Microsoft.Azure.PowerShell.Cmdlets.Functions.Cmdlets.NewAzFunctionApp_Create
VERBOSE: Your Linux function app 'bvtMLtmp', that uses a consumption plan has been successfully created but is not active until content is published using Azure Portal or the Functions Core Tools.

> $?
$true
```

This is both incorrect and misleading. It implies that the function app has been successfully created.
Note that the same action in the Portal generates an intelligible response:

```
{
"code":"InvalidTemplateDeployment",
"message":"The template deployment 'Microsoft.Web-FunctionApp-Portal-d42b6bbc-a482' is not valid according to the validation procedure. The tracking id is '34fa672e-ad3f-4dca-91ac-89f79c2cb225'. See inner errors for details.",
"details":[
{
"code":"ValidationForResourceFailed",
"message":"Validation failed for a resource. Check 'Error.Details[0]' for more information.",
"details":[
{
"code":"LinuxWorkersNotAllowedInResourceGroup",
"message":"Linux workers are not available in resource group NfvTest. Use this link to learn more https://go.microsoft.com/fwlink/?linkid=831180"
}
]
}
```

## Module versions

```
Script 1.0.2 Az.Functions {Get-AzFunctionApp, Get-AzFunctionAppAvailableLocation, Get-AzFunctionAppPlan, Get-AzFunctionAppSetting...}

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.