<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>azure function yaml template and release &#8211; Sibeesh Passion</title>
	<atom:link href="https://sibeeshpassion.com/tag/azure-function-yaml-template-and-release/feed/" rel="self" type="application/rss+xml" />
	<link>https://sibeeshpassion.com</link>
	<description>My passion towards life</description>
	<lastBuildDate>Tue, 13 May 2025 20:06:24 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>

<image>
	<url>/wp-content/uploads/2017/04/Sibeesh_Passion_Logo_Small.png</url>
	<title>azure function yaml template and release &#8211; Sibeesh Passion</title>
	<link>https://sibeeshpassion.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Linux Azure Function Isolated Dot Net 9 YAML Template Deployment</title>
		<link>https://sibeeshpassion.com/linux-azure-function-isolated-dot-net-9-yaml-template-deployment/</link>
					<comments>https://sibeeshpassion.com/linux-azure-function-isolated-dot-net-9-yaml-template-deployment/#disqus_thread</comments>
		
		<dc:creator><![CDATA[SibeeshVenu]]></dc:creator>
		<pubDate>Sun, 27 Apr 2025 11:05:56 +0000</pubDate>
				<category><![CDATA[Azure]]></category>
		<category><![CDATA[Azure Function]]></category>
		<category><![CDATA[azure function release pipeline]]></category>
		<category><![CDATA[azure function worker process]]></category>
		<category><![CDATA[azure function yaml template and release]]></category>
		<category><![CDATA[dot net 9]]></category>
		<category><![CDATA[dotnet-isolated]]></category>
		<guid isPermaLink="false">https://sibeeshpassion.com/?p=14697</guid>

					<description><![CDATA[Introduction In this post, let&#8217;s see how we can deploy a dot net 9 isolated runtime model project to a Linux based Azure function. Prerequisites Creating the hosting plan It is not mandatory to create a hosting plan, as the resource will be auto created when you create the function, however it is recommended to create one as you can define your naming strategies and more controls. Here we are choosing the consumption plan. You can learn more about the hosting options Azure provides here. Below is the ARM template to create the consumption hosting plan. Creating the Azure function [&#8230;]]]></description>
										<content:encoded><![CDATA[
<h1 class="wp-block-heading">Introduction</h1>



<p>In this post, let&#8217;s see how we can deploy a dot net 9 isolated runtime model project to a Linux based Azure function.</p>



<h1 class="wp-block-heading"><strong>Prerequisites</strong></h1>



<h2 class="wp-block-heading"><strong>Creating the hosting plan</strong></h2>



<p>It is not mandatory to create a hosting plan, as the resource will be auto created when you create the function, however it is recommended to create one as you can define your naming strategies and more controls. Here we are choosing the consumption plan. You can learn more about the hosting options Azure provides <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-scale">here</a>. Below is the ARM template to create the consumption hosting plan.</p>



<pre class="wp-block-code"><code>{
    "type": "Microsoft.Web/serverfarms",
    "apiVersion": "2024-04-01",
    "name": "&#91;parameters('funcAppServerFarmName')]",
    "location": "&#91;parameters('funcAppLocation')]",
    "kind": "functionapp",
    "sku": {
        "name": "Y1",
        "tier": "Dynamic"
    },
    "properties": {
        "computeMode": "Dynamic",
        "reserved": true
    }
}</code></pre>



<p><strong>Creating the Azure function</strong></p>



<p>Below is the ARM template to create the Azure function.</p>



<pre class="wp-block-code"><code>{
    "type": "Microsoft.Web/sites",
    "apiVersion": "2024-04-01",
    "name": "&#91;parameters('FuncName')]",
    "location": "&#91;parameters('funcAppLocation')]",
    "kind": "functionapp,linux",
    "identity": {
        "type": "SystemAssigned"
    },
    "properties": {
        "reserved": true,
        "alwaysOn": true,
        "serverFarmId": "&#91;resourceId('Microsoft.Web/serverfarms', parameters('funcAppServerFarmName'))]",
        "linuxFxVersion": "DOTNET-ISOLATED|9.0",
        "siteConfig": {
            "linuxFxVersion": "DOTNET-ISOLATED|9.0",
            "appSettings": &#91;
                {
                    "name": "AzureWebJobsStorage",
                    "value": "&#91;format('DefaultEndpointsProtocol=https;AccountName={0};EndpointSuffix={1};AccountKey={2}', parameters('StorageName'), environment().suffixes.storage, listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('StorageName')), '2022-05-01').keys&#91;0].value)]"
                },
                {
                    "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                    "value": "&#91;reference(resourceId('Microsoft.Insights/components', parameters('InsightsComponentName')), '2020-02-02').InstrumentationKey]"
                },
                {
                    "name": "FUNCTIONS_EXTENSION_VERSION",
                    "value": "~4"
                },
                {
                    "name": "FUNCTIONS_WORKER_RUNTIME",
                    "value": "dotnet-isolated"
                },
                {
                    "name": "linuxFxVersion",
                    "value": "DOTNET-ISOLATED|9.0"
                },
                {
                    "name": "WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED",
                    "value": "1"
                },
                {
                    "name": "CosmosConnectionString",
                    "value": "&#91;concat('@Microsoft.KeyVault(SecretUri=', 'https://',parameters('KeyVaultName'),'.vault.azure.net/secrets/CosmosConnectionString)')]"
                }
            ],
            "minTlsVersion": "1.3"
        },
        "runtime": {
            "name": "dotnet-isolated"
        },
        "httpsOnly": true
    },
    "dependsOn": &#91;
        "&#91;resourceId('Microsoft.Insights/components', parameters('InsightsComponentName'))]",
        "&#91;resourceId('Microsoft.Web/serverfarms', parameters('funcAppServerFarmName'))]",
        "&#91;resourceId('Microsoft.Storage/storageAccounts', parameters('StorageName'))]"
    ]
}</code></pre>



<p>Please make sure to set the values linuxFxVersion, WEBSITE_USE_PLACEHOLDER_DOTNETISOLATED or you may get the error below when you deploy your code to the Azure function.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><em>Failed to sync triggers for function app &#8216;funcsintest03&#8217;. Error: BadRequest &#8211; Encountered an error (BadGateway) from host runtime. (CODE: 400)</em></p>
</blockquote>



<p>I have a detailed post on the error <a href="https://stackoverflow.com/a/79594377/5550507">here on Stack Overflow</a>. Here is a doc on <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-infrastructure-as-code?pivots=consumption-plan&amp;tabs=json%2Clinux%2Cdevops">Automate resource deployment for your function app in Azure Functions</a>.</p>



<h1 class="wp-block-heading">Create Azure function application</h1>



<p>You can easily create the Azure function using the <a href="https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio">Visual Studio by following this post</a>. Please be noted that for my Azure function I am choosing my function to run in an isolated worker process to get the benefits like standard dependency injection, you can read more on this <a href="https://learn.microsoft.com/en-us/azure/azure-functions/dotnet-isolated-process-guide?tabs=hostbuilder%2Clinux">here</a>.</p>



<h1 class="wp-block-heading">Create the Azure DevOps pipelines</h1>



<p>Before we create the pipelines, let’s create the template YAML with the file name as func-template.yml so that we can use it for all of our environments like Dev, Test, Prod etc.</p>



<pre class="wp-block-code"><code>parameters:
  - name: azureSubscriptionServiceConnection
    type: string
  - name: functionAppName
    type: string
  - name: stageName
    type: string

stages:
  - stage: ${{ parameters.stageName }}_Stage
    displayName: Release stage ${{ parameters.stageName }}
    jobs:
      - job: ${{ parameters.stageName }}_Release
        displayName: ${{ parameters.stageName }}_Release
        pool:
          vmImage: "ubuntu-latest"
        steps:
          # Download an artifact named 'WebApp' to 'bin' in $(Build.SourcesDirectory)
          - task: DownloadPipelineArtifact@2
            inputs:
              artifactName: "drop"
              targetPath: $(Build.SourcesDirectory)/bin
          - task: AzureFunctionApp@2 # Add this at the end of your file
            inputs:
              azureSubscription: ${{ parameters.azureSubscriptionServiceConnection }}
              appType: functionAppLinux # This specifies a Linux-based function app
              #isFlexConsumption: true # Uncomment this line if you are deploying to a Flex Consumption app
              appName: ${{ parameters.functionAppName }}
              package: $(Build.SourcesDirectory)/bin/*.zip
              deploymentMethod: "zipDeploy" # 'auto' | 'zipDeploy' | 'runFromPackage'. Required. Deployment method. Default: auto.
              #Uncomment the next lines to deploy to a deployment slot
              #Note that deployment slots is not supported for Linux Dynamic SKU
              #deployToSlotOrASE: true
              #resourceGroupName: '&lt;RESOURCE_GROUP>'
              #slotName: '&lt;SLOT_NAME>'
              runtimeStack: 'DOTNET-ISOLATED|9.0'
</code></pre>



<p>Here we use the task AzureFunctionApp@2 task, you can learn more about that task <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/azure-function-app-v2?view=azure-pipelines">here</a>. Next, create a YAML file func-template.yml with the contents below.</p>



<pre class="wp-block-code"><code>trigger:
  - main
stages:
  - stage: Build
    displayName: Build and push stage
    jobs:
      - job: Build
        displayName: Build
        pool:
          vmImage: "ubuntu-latest"
        steps:
          - task: UseDotNet@2
            inputs:
              packageType: "sdk"
              version: "9.0.x" # .NET 9 preview/stable depending on your needs
              installationPath: $(Agent.ToolsDirectory)/dotnet
          - checkout: self
          - script: |
              dotnet restore
              dotnet build --configuration Release
          - task: DotNetCoreCLI@2
            inputs:
              command: publish
              arguments: "--configuration Release --output publish_output"
              projects: "$(System.DefaultWorkingDirectory)/MyFunc.Func/MyFunc.Func.csproj"
              publishWebProjects: false
              modifyOutputPath: false
              zipAfterPublish: false
          - task: ArchiveFiles@2
            displayName: "Archive files"
            inputs:
              rootFolderOrFile: "$(System.DefaultWorkingDirectory)/publish_output"
              includeRootFolder: false
              archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
          - task: PublishBuildArtifacts@1
            inputs:
              PathtoPublish: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
              artifactName: "drop"

  - template: func-template.yml
    parameters:
      azureSubscriptionServiceConnection: "MyFuncdevmi"
      functionAppName: "MyFuncfuncsindev03"
      stageName: "DEV"
  - template: func-template.yml
    parameters:
      azureSubscriptionServiceConnection: "MyFunctestmi"
      functionAppName: "MyFuncfuncsintest03"
      stageName: "TEST"
</code></pre>



<p>In the above YAML file, my function project name is MyFunc and I am using the MyFuncdevmi as the service connection to deploy the Azure function to the DEV environment MyFuncfuncsindev03 and MyFunctestmi to deploy to my TEST environment MyFuncfuncsintest03.</p>



<p>I am using managed identity to create those service connection. You can create a managed identity using the ARM template below.</p>



<pre class="wp-block-code"><code>{
    "type": "Microsoft.ManagedIdentity/userAssignedIdentities",
    "apiVersion": "2024-11-30",
    "name": "&#91;parameters('managedIdentityName')]",
    "location": "&#91;parameters('location')]",
    "tags": {
        "{customized property}": "string"
    }
}&nbsp; &nbsp; &nbsp;</code></pre>



<p>You can follow this doc to create the <a href="https://learn.microsoft.com/en-us/azure/devops/pipelines/library/connect-to-azure?view=azure-devops">service connection using the managed identity</a>.</p>



<h1 class="wp-block-heading">Create the pipeline using the YAMLs created</h1>



<p>Go to the Pipeline menu and click on New pipeline button. Select your Azure DevOps repository and click on the option Existing Azure Pipelines YAML file. </p>



<figure class="wp-block-image size-large"><a href="/wp-content/uploads/2025/04/image.png"><img fetchpriority="high" decoding="async" width="1024" height="434" src="/wp-content/uploads/2025/04/image-1024x434.png" alt="" class="wp-image-14699" srcset="/wp-content/uploads/2025/04/image-1024x434.png 1024w, /wp-content/uploads/2025/04/image-300x127.png 300w, /wp-content/uploads/2025/04/image-768x325.png 768w, /wp-content/uploads/2025/04/image-1536x651.png 1536w, /wp-content/uploads/2025/04/image-2048x867.png 2048w, /wp-content/uploads/2025/04/image-400x169.png 400w, /wp-content/uploads/2025/04/image-1417x600.png 1417w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<p>Choose the path to your release pipeline YAML file, not the template YAML file, and run your pipeline. If your pipeline is successful, you should be able to see the output as below.</p>



<figure class="wp-block-image size-large"><a href="/wp-content/uploads/2025/04/image-3.png"><img decoding="async" width="1024" height="364" src="/wp-content/uploads/2025/04/image-3-1024x364.png" alt="" class="wp-image-14704" srcset="/wp-content/uploads/2025/04/image-3-1024x364.png 1024w, /wp-content/uploads/2025/04/image-3-300x107.png 300w, /wp-content/uploads/2025/04/image-3-768x273.png 768w, /wp-content/uploads/2025/04/image-3-1536x546.png 1536w, /wp-content/uploads/2025/04/image-3-2048x728.png 2048w, /wp-content/uploads/2025/04/image-3-400x142.png 400w, /wp-content/uploads/2025/04/image-3-1689x600.png 1689w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<figure class="wp-block-image size-large"><a href="/wp-content/uploads/2025/04/image-1.png"><img decoding="async" width="1024" height="270" src="/wp-content/uploads/2025/04/image-1-1024x270.png" alt="" class="wp-image-14700" srcset="/wp-content/uploads/2025/04/image-1-1024x270.png 1024w, /wp-content/uploads/2025/04/image-1-300x79.png 300w, /wp-content/uploads/2025/04/image-1-768x202.png 768w, /wp-content/uploads/2025/04/image-1-1536x404.png 1536w, /wp-content/uploads/2025/04/image-1-2048x539.png 2048w, /wp-content/uploads/2025/04/image-1-400x105.png 400w" sizes="(max-width: 1024px) 100vw, 1024px" /></a></figure>



<h1 class="wp-block-heading">Conclusion</h1>



<p>In this post we have learned how to,</p>



<ul class="wp-block-list">
<li>create the Azure function and consumption hosting plan with dotnet isolated worker process</li>



<li>create the temple for the deploying the Azure function</li>



<li>create the release YAML using the template file</li>
</ul>



<h1 class="wp-block-heading">About the Author</h1>



<p>I am yet another developer who is passionate about writing and sharing knowledge. I have written more than 500 blogs on my&nbsp;<a rel="noreferrer noopener" href="https://sibeeshpassion.com/" target="_blank">blog</a>. If you like this content, consider following me here,</p>



<ul class="wp-block-list">
<li><a href="https://github.com/SibeeshVenu">GitHub</a></li>



<li><a href="https://medium.com/@sibeeshvenu">medium</a></li>



<li><a href="https://twitter.com/sibeeshvenu">Twitter</a></li>
</ul>



<h1 class="wp-block-heading">Your turn. What do you think?</h1>



<p>Thanks a lot for reading. Did I miss anything that you may think is needed in this article? Could you find this post useful? Kindly do not forget to share your feedback.</p>



<p></p>
]]></content:encoded>
					
					<wfw:commentRss>https://sibeeshpassion.com/linux-azure-function-isolated-dot-net-9-yaml-template-deployment/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
