Deploying an Azure Web App via Bicep does not set Stack - azure-web-app-service

I am creating an Azure Web App via Bicep to host an ASP.NET Core 7.0 Website. My Bicep contains:
netFrameworkVersion: 'v7.0'
requestTracingEnabled: true
remoteDebuggingEnabled: true
remoteDebuggingVersion: 'VS2022'
httpLoggingEnabled: true
use32BitWorkerProcess: false
ftpsState: 'FtpsOnly'
managedPipelineMode: 'Integrated'
But when I deploy the Bicep it is not being set to .NET 7 and the settings look like below:
I found some posts on SO that suggests some solution for metadata but I am not sure how and if this solution apply to .NET 7.
Are you aware of any missing setting that I need to add to have this set to the picture below:

If you want to deploy Linux web app, use linuxFxVersion parameter:
linuxFxVersion: 'DOTNETCORE|7.0'
For windows deployment, use the following parameters:
metadata :[
{
name:'CURRENT_STACK'
value:'dotnet'
}
]
netFrameworkVersion:'v7.0'
Full bicep available in this question

Related

Azure Bicep - Connect Azure API Management (API) to Azure Function App

I can see within the Azure Management Console, specifically within the Azure API Management Service, via the GUI you are able to use Azure Functions to form an API.
I am trying to implement the same via Azure Bicep, but I do not see any options in the Bicep documentation for API Management - API Service.
In the GUI, I see something like this:
This allows me to specify my Function App:
However, within the Bicep Documentation, I don't see anything where I would expect to: Microsoft.ApiManagement service/apis
I have instead tried using the Microsoft.ApiManagement service/backends but that doesn't give the same experience and I haven't managed to get that to work.
So my question is, how do I connect my Azure API Management service to an Azure Site (app) which is set as a suite of Azure Functions?
You need to create backend and all api definitions manually. The portal gives you a nice creator and does all those REST calls for you. With bicep (and ARM) which is operating directly on the REST endpoints of each resource provider you need to build own solution.
Perhaps there’re somewhere some existing templates that can do this but personally I didn’t see any yet.
I added OpenAPI specifications to my functionApps to produce the sawgger \ -openAPI link (or file). Then leveraged the OpenAPI file to build the APIs.
// Create APIM Service
resource apimServiceRes 'Microsoft.ApiManagement/service#2021-08-01' = {
name: 'apim service name'
location: resourceGroup().location
sku:{
capacity: 0
name: 'select a sku'
}
identity:{
type: 'SystemAssigned'
}
properties:{
publisherName: 'your info'
publisherEmail: 'your info'
}
}
// Create the API Operations with:
resource apimApisRes 'Microsoft.ApiManagement/service/apis#2021-08-01' = {
name: '${apimServiceRes.name}/name-to-represent-your-api-set'
properties: {
format: 'openapi-link'
value: 'https://link to your swagger file'
path: ''
}
}

Is it possible to do continuous deployment CI/CD of an Azure Function through a Linux Environment via Azure DevOps?

When creating a function in Azure through a Linux environment it seems CI/CD is completely missing from it's capabilities as I can't see any actual files. My VS code tells me this
Error: This plan does not support viewing files.
and when I try to deploy my files to the server through the Azure pipeline everything works except for the
Azure App Service Deploy
Which tells me this.
2020-04-21T19:48:37.6676043Z ##[error]Failed to deploy web package to App Service.
2020-04-21T19:48:37.6689536Z ##[error]Error: Error: Failed to deploy web package to App Service. Conflict (CODE: 409)
I did get it working directly through VS Code with a windows environment and didn't notice any of those issues.
Can you confirm this is not possible through Linux or perhaps there is a solution for what I am looking for.
is it possible to do continuous deployment CI/CD of an Azure Function through a Linux Environment via Azure DevOps?
The answer is Yes.
To deploy a Azure Function, you should use Azure Function App task instead of Azure App Service Deploy task. For below example.
steps:
- task: AzureFunctionApp#1
inputs:
azureSubscription: '<Azure service connection>'
appType: functionAppLinux
appName: '<Name of function app>'
#Uncomment the next lines to deploy to a deployment slot
#Note that deployment slots is not supported for Linux Dynamic SKU
#deployToSlotOrASE: true
#resourceGroupName: '<Resource Group Name>'
#slotName: '<Slot name>'
Please check out this document Continuous delivery by using Azure DevOps for detailed examples.

How to associate an Azure app service with an application insights resource (new or existing) using terraform?

I looked at the documentation of both azurerm_app_service and azurerm_application_insights and I just do not see a way to tie them.
Yet on the App Service page in the portal there is a link to Application Insights, currently grayed out:
So, how do I enable it with terraform?
You need numerous app settings to get this to work properly as intended. The ones I had to add to get it all working were:
"APPINSIGHTS_INSTRUMENTATIONKEY"
"APPINSIGHTS_PROFILERFEATURE_VERSION"
"APPINSIGHTS_SNAPSHOTFEATURE_VERSION"
"APPLICATIONINSIGHTS_CONNECTION_STRING"
"ApplicationInsightsAgent_EXTENSION_VERSION"
"DiagnosticServices_EXTENSION_VERSION"
"InstrumentationEngine_EXTENSION_VERSION"
"SnapshotDebugger_EXTENSION_VERSION"
"XDT_MicrosoftApplicationInsights_BaseExtensions"
"XDT_MicrosoftApplicationInsights_Mode"
It seems that enabling application insights using Terraform is not working yet currently. There is a Feature Request: Attach azurerm_application_insights to a azurerm_app_service in Github.
It might be possible to set a tag on the azurerm_application_insights resource,
resource "azurerm_application_insights" "test" {
tags {
"hidden-link:/subscriptions/<subscription id>/resourceGroups/<rg name>/providers/Microsoft.Web/sites/<site name>": "Resource"
}
}
Usually, if you need to enable application insights component in your app service, you need to add APPINSIGHTS_* environment variables to the app_settings of your web app.
For example,
app_settings {
"APPINSIGHTS_INSTRUMENTATIONKEY" = "${azurerm_application_insights.test.instrumentation_key}"
}
See argument reference even it's about Azure function.
ref:
https://www.olivercoding.com/2018-06-24-terraform/
https://github.com/terraform-providers/terraform-provider-azurerm/issues/2457

Azure publish completes, but the site shows next steps to deploy

I have an asp.net core 2.0 website built in VS19 that I am deploying to an Azure app service. The source code repo is in Azure Dev Ops, but I want to deploy directly from my local machine.
In Azure I created the Azure App Service and downloaded the 'Publish Profile' and imported it to VS2019 and executed the Publish. The output window shows that everything was deployed successfully.
However, when I navigate to the deployment url, I get this screen instead of my app.
What am I doing wrong? There isn't any error messages, so I can't really search.
EDIT: In startup.cs, my default route is in an Area. So I have the following defined:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "areaRoute",
template: "{area:exists}/{controller=Account}/{action=Login}");
routes.MapAreaRoute(
name: "default",
areaName: "Home",
template: "{controller=Account}/{action=Login}");
//routes.MapRoute(
// name: "default",
// template: "{controller=Home}/{action=Index}/{id?}");
});
This happens if you dont have the starting page above the hostingstart.html . Make sure you default page is listed in here and is above hostingstart.html so that will be picked by default.
If you are wondering how to do
On Windows OS:
“App Services” blade > Select your “Web app”, click on “Configuration” and Default Documents "
Linux OS:
If the webApp has linux OS it wont have the default documents, you need to set
the startup command as dotnet yourapp.dll under general settings
Also make sure to check "Remove additional files at destination button during republish" on Visual Studio. That will remove the files existing in the WebApp before upload the files.

How to disable ftps/ftp in Azure Functions App using ARM template

I'm deploying an Azure Functions App using an ARM template and want to disable ftp/ftps access.
The setting is easy to find in the portal:
How do I find the property or app setting for this so I can configure it in the json ARM template?
I've already tried
Reviewing Microsoft documentation
Running PowerShell commands Get-AzureRmResource and Get-AzureRmWebApp to explore the returned site objects
Searching for the property in the Azure Resource Explorer
Guessing the property name and testing deployments--trial and error
I would expect the setting to exist along with similar settings in the siteConfig:
The property you are looking for is ftpsState. Here are the possible values:
AllAllowed (that's the default)
FtpsOnly
Disabled

Resources