Azure DevOps Variable Group not applying in Azure Function Configuration - azure

I am trying to leverage the Variable Group functionality in Azure DevOps.
I have created the variable group within the Release pipeline and I have associated. However, when I release the code to the Function App in Azure; when I go to the Configuration settings in the Function app, the custom settings are not there.
Is there a step I am missing here on getting these to show up?
UPDATE: To fix this; I needed to write the variables. This is the step I did it.

I usually do this using a powershell task after publishing the new code. So add a new powershell task and define it as inline:
$appname = "name of your function app"
$rg = "name of resource group"
$webApp = Get-AzureRmwebApp -ResourceGroupName $rg -Name $appname
$webAppSettings = $webApp.SiteConfig.AppSettings
$hash = #{}
foreach ($setting in $webAppSettings) {
$hash[$setting.Name] = $setting.Value
}
$hash['New name'] = $("pipelineVariable")
Set-AzureRMWebAppSlot -ResourceGroupName $rg -Name $appname -AppSettings $hash -Slot production
PS: define the deployment slot as a variable too

Related

Getting vnet integration infos from a service plan

CONTEXT
Whe deploy an Azure Function with a vnet integration with a code like this:
$properties = #{
subnetResourceId = $subnet.Id
}
$vNetParams = #{
ResourceName = "$webapp/VirtualNetwork"
Location = $Location
ResourceGroupName = $ResourceGroupName
ResourceType = "Microsoft.Web/sites/networkConfig"
PropertyObject = $properties
}
$result = New-AzResource #vNetParams -Force
This works fine.
The project get $subnet by looking an available subnet into a spoke VNET.
So I don't want to run the previous code when a VNET integration already exists.
WHAT I NEED
A way to know if a Function has already a VNET integration
WHAT I TESTED
Get-AzFunctionApp -ResourceGroupName $ResourceGroupName -Name $webapp
Get-AzFunctionAppPlan -ResourceGroupName $ResourceGroupName -Name $servicePlan
Get-AzAppServicePlan -ResourceGroupName $ResourceGroupName -Name $servicePlan
Returns no vnet informations
Get-AzResource doesn't work with this resource: "$webapp/VirtualNetwork" (not found)
To check if a function app has already a vnet integration, just use the command below.
$VnetName = (Get-AzFunctionApp -ResourceGroupName <groupname> -Name <functionappname>).SiteConfig.VnetName
if($VnetName){
Write-Output "already intergration"
}
There is a way to figure this in portal.
Navigate to Azure portal
Select the corresponding Web App or Function App
Navigate to "Diagnose and solve problems" and search for "VNet Integration Information"
This will load a blade, which will have details of the Web App in that App Service Plan
This is what the UI looks like

How to enable Soft Delete on an existing Azure KeyVault

I know how to enable soft delete (https://learn.microsoft.com/en-us/azure/key-vault/key-vault-ovw-soft-delete) via template deployment when creating a KeyVault. How can I turn this feature on on an existing KeyVault that has been deployed without soft delete being enabled?
It is of course possible to adjust the template to include the enablement of soft-delete by adding the key-value pair "enableSoftDelete": true to the properties section of the KeyVault resource (see also: Link).
If you want to enable it outside the scope of a template deployment it is possible via manipulating the resource e.g. by using PowerShell:
$vaultName = "keyVaultName1"
($resource = Get-AzureRmResource -ResourceId (Get-AzureRmKeyVault -VaultName $vaultName).ResourceId).Properties | Add-Member -MemberType "NoteProperty" -Name "enableSoftDelete" -Value "true"
Set-AzureRmResource -resourceid $resource.ResourceId -Properties $resource.Properties
Found here: Link

Set VSO build/release number as Azure application setting

I'm using Visual Studio Online as a build server. How can I set the build & release numbers as an Application Setting in the Azure deploy step of a release definition?
Assuming that you're able to get these numbers (which you should using available variables from https://www.visualstudio.com/pl-pl/docs/build/concepts/definitions/release/variables#default-variables), you can update web app's settings by using Azure PowerShell task with a script (or two) like:
param (
[string]$WebAppName,
[string]$SettingName,
[string]$SettingValue
)
$webApp = Get-AzureRmWebApp -Name $WebAppName
$appSettingsList = $webApp.SiteConfig.AppSettings
$hashList = #{}
foreach ($kvp in $appSettingsList) {
$hashList[$kvp.Name] = $kvp.Value
}
$hashList[$SettingName] = $SettingValue
Set-AzureRmWebApp -ResourceGroupName $webApp.ResourceGroup -Name $WebAppName -AppSettings $hashList
where SettingName and SettingValue are name and value of app setting you want to add/modify.
So script arguments may look like -WebAppName your-web-app -SettingName ReleaseNumber -SettingValue $(Release.ReleaseId).

How to rename existing Azure Logic App?

I have created a logic app, but now I want to rename existing logic app in Microsoft Azure portal.
I have been looking for options, but could not find one.
You cannot rename web app as far as I'm aware. You can redeploy using different name and then delete existing one.
Select the LogicApp, clone it with a new name, delete the old one.
Existing logic app cannot be renamed. we can clone the existing logic app with a new name.
However,the cloned logic app will be created in the same resource group of the existing logic app. we can change the resource group or location of the logic app once the cloning is completed, but in order to avoid any run time error we need to update the subscription/Resource group name or id in the code view.
You can't rename Logic App... however you can redeploy it in minutes using PowerShell
If you just want workflow definition then
$rg = "my-resoruce-group"
$logicAppName = "my-logic-app"
$newName = "my-new-name"
$logicApp = Get-AzLogicApp -ResourceGroupName $rg -Name $logicAppName
New-AzLogicApp `
-ResourceGroupName $rg `
-Name "New-Name" `
-Definition $logicApp.Definition `
-Location $logicApp.Location
Or export entire resource as ARM template and reploy it either via PowerShell, CLI or through portal
$rg = "my-resoruce-group"
$logicAppName = "my-logic-app"
$logicApp = Get-AzLogicApp -ResourceGroupName $rg -Name $logicAppName
Export-AzResourceGroup `
-ResourceGroupName $rg `
-Resource $logicApp.Id `
-Path "arm.json"
One cannot able to rename the logic app , you can able to clone the logic app with the option available in overview section of logic app as available in below picture and provide the new name. Once the new logic app gets created we can delete the old logic app.

Azure: Powershell: Set-AzureRmWebApp: How to set the "alwaysOn" property

I am running Powershell 5 and trying to manipulate my Azure WebApp object using Set-AzureRmWebApp (and NOT Set-AzureResource) to set the "Always On" property of the web app.
My basic code snippet starts with a running web app named "myWebApp", and looks like this:
$name = "myWebApp"
$resourceGroupName = "myResourceGroup"
$app_settings = #{"WEBSITE_LOAD_CERTIFICATES"="*";"CommonDatabase"="Common";"WEBSITE_NODE_DEFAULT_VERSION"="0.10.32"}
$result1 = Set-AzureRmWebApp -ResourceGroupName $resourceGroupName -AppSettings $app_settings -Name $name
$result2 = Set-AzureRmResource -ResourceGroupName $resourceGroupName -ResourceType Microsoft.Web/sites/config -ResourceName $this.name -PropertyObject $propertiesObject -ApiVersion 2015-08-01 -Force
The first Set-AzureRmWebApp statement works. It sets all the variables in $app_settings, and they become visible in the Azure Portal blade for myWebApp.
I tried using "Always On"= on as a property in $app_settings with Set-AzureRmWebApp, and it appeared in the App Settings sub-list in the properties of "myWebApp" on the Azure portal blade, but the actual property "Always On" in the general settings remained off.
I read on another site that using Set-AzureRmResource would work, so I tried it, but it failed.
What do I need to do in Powershell to set a property in the General Settings of my Azure WebApp, specifically "Always On"?
"Always On" is not supported if WebApp is in a free Service Plan tier. If the WebApp is in a free tier, please scale up the App Service Plan. Please refer to the document for more info about how to scale up the App Service Plan.Please have a try to use the solution that sharbag mentioned. It is worked for me and I also check the run result from the azure portal. Snipped code from the solution is as followings:
$ResourceGroupName = 'Your Group Name'
$WebAppName = 'Your WebApp Name'
$WebAppPropertiesObject = #{"siteConfig" = #{"AlwaysOn" = $true}}
$WebAppResourceType = 'microsoft.web/sites'
$webAppResource = Get-AzureRmResource -ResourceType $WebAppResourceType -ResourceGroupName $ResourceGroupName -ResourceName $WebAppName
$webAppResource | Set-AzureRmResource -PropertyObject $WebAppPropertiesObject -Force
If the WebApp in a free tier service plan, when we try to run the PowerShell command to enable "Always On" then we will get the following error message.

Resources