Skip to content

[BUG]: AzureFunctionApp@2 Uses Invalid Resource Type API Version for Azure Functions (2016-07-01) #20841

@BernieEllis

Description

@BernieEllis

New issue checklist

Task name

AzureFunctionApp@2

Task version

2.247.1

Issue Description

When using the AzureFunctionApp@2 deploy task, I constantly get the error:

##[debug]Deployment Failed with Error: Error: Resource '' doesn't exist. Resource should exist before deployment.
##[debug]task result: Failed

Problem is, the function app 100% does exist, and if I switch to AzureCLI@2 for the deployment task...it succeeds.

It seems the core issue is the 2016-07-01 API version being used to get the instance of the function app. From checking Microsoft.Web/sites ARM REST API documentation, it appears that API version is not valid.

To prove this, I can launch Azure Cloud Shell and run the below command with just about any valid API version from the documentation and get a success, but of course fails using the API version above:

Succeeds:

az rest --method get --url "https://management.azure.com/subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Web/sites/<functionAppName>?api-version=2024-04-01"

Fails:

az rest --method get --url "https://management.azure.com/subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Web/sites/<functionAppName>?api-version=2016-07-01"

I don't understand why the AzureFunctionApp@2 is using such an outdated, and actually invalid, API version for function apps and I don't see a way to specify other valid versions.

Is the Microsoft team aware of this, and if so, is there a fix planned for this?

Thanks,
Bernie

Environment type (Please select at least one enviroment where you face this issue)

  • Self-Hosted
  • Microsoft Hosted
  • VMSS Pool
  • Container

Azure DevOps Server type

dev.azure.com (formerly visualstudio.com)

Azure DevOps Server Version (if applicable)

No response

Operation system

Ubuntu-Latest (Happens on Windows also, however)

Relevant log output

##[debug][GET]https://management.azure.com/subscriptions/<subscriptionId>/resources?$filter=resourceType EQ 'Microsoft.Web%2FSites' AND name EQ '<FunctionApp-Name>'&api-version=**2016-07-01**
##[debug]Correlation ID from ARM api call response : 1c8e80db-0c04-4beb-8468-00da2472b64d
##[debug]Deployment Failed with Error: Error: Resource '<FunctionApp-Name>' doesn't exist. Resource should exist before deployment.
##[debug]task result: Failed
##[error]Error: Resource '<FunctionApp-Name>' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.issue type=error;source=TaskInternal;correlationId=e148e545-b00c-48d1-bc9d-5fd89395a1fe;]Error: Resource '<FunctionApp-Name>' doesn't exist. Resource should exist before deployment.
##[debug]Processed: ##vso[task.complete result=Failed;]Error: Resource '<FunctionApp-Name>' doesn't exist. Resource should exist before deployment.

Full task logs with system.debug enabled

 [REPLACE THIS WITH YOUR INFORMATION] 

Repro steps

trigger: none

variables:
  # Azure Resource Manager connection created during pipeline creation
  azureSubscription: '<ServiceConnection>'

  # Resource Group Name
  resourceGroupName: '<ResourceGroupName>'

  # Function app name
  functionAppName: '<FunctionAppName>'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'

  # Working Directory
  workingDirectory: '$(System.DefaultWorkingDirectory)/Code.Functions'

stages:
- stage: Build
  displayName: Build stage

  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)

    steps:
    - task: DotNetCoreCLI@2
      displayName: Build Project
      inputs:
        command: 'build'
        projects: |
          $(workingDirectory)/*.csproj
        arguments: --output $(System.DefaultWorkingDirectory)/publish_output --configuration Release

    - task: ArchiveFiles@2
      displayName: 'Archive Build files'
      inputs:
        rootFolderOrFile: '$(System.DefaultWorkingDirectory)/publish_output'
        includeRootFolder: false
        archiveType: zip
        archiveFile: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
        replaceExistingArchive: true

    - publish: $(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip
      artifact: drop

- stage: Deploy
  displayName: Deploy stage
  dependsOn: Build
  condition: succeeded()

  jobs:
  - deployment: Deploy
    displayName: Deploy to Azure Function App
    environment: 'development'
    pool:
      vmImage: $(vmImageName)

    strategy:
      runOnce:
        deploy:

          steps:
          - task: AzureFunctionApp@2
            displayName: 'Deploy to Azure Functions'
            inputs:
              azureSubscription: '$(azureSubscription)'
              appType: functionAppLinux
              isFlexConsumption: true
              appName: $(functionAppName)
              package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip'
              deploymentMethod: 'auto'

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions