Closed stevemorris1106 closed 2 years ago
Is there any alternative way to keep it as IaaC? Like ARM Template for only virtual path, physical path configs? Any suggestions?
Is there any alternative way to keep it as IaaC? Like ARM Template for only virtual path, physical path configs? Any suggestions?
I scripted it out using Powershell. Here is the function I wrote, you will have to change it to meet your needs. I think you can this inline in your TF code, or add it as a configuration management script somewhere. Im doing a runonce on a script after Terraform provisions to set all of the things I cannot in TF.
Edit: Formatting is getting jacked up sorry.
function Set-WebAppVirtualDirectory { <# .SYNOPSIS Used for setting the Path mappings of an Azure WebApp
.DESCRIPTION
Sets the virtual path of the siteconfig object in an Azure WebApp
.EXAMPLE
Set-WebAppVirtualDirectory -Branch "something" -Product "somecoolproduct" -Environment "dev" -VirtualPath "/thepath" -PhysicalPath "site\wwwroot\mysite"
.PARAMETER Branch
Branch for the specific set of Azure Resources
.PARAMETER Environment
Environment for the specific set of Azure Resources
.PARAMETER VirtualPath
Virtual directory for the WebApp
.PARAMETER Product
Product for the app, like mycoolapp
.PARAMETER PhysicalPath
Physical location of the files within Azure
.PARAMETER PreloadEnabled
Preload is set to false by default
#>
param(
[Parameter(Mandatory=$true)][string]$Branch,
[Parameter(Mandatory=$true)][string]$Environment,
[Parameter(Mandatory=$true)][string]$Product,
[Parameter(Mandatory=$true)][string]$VirtualPath,
[Parameter(Mandatory=$true)][string]$PhysicalPath,
[string]$PreloadEnabled = "false"
)
$azureWebAppName = "$($Branch)-$($Product)-$($Environment)"
$azureResourceGroup = "$($Branch)-$($Product)-$($Environment)-rg"
$webApp = Get-AzWebApp -Name $azureWebAppName -ResourceGroupName $azureResourceGroup
$virtApp = New-Object Microsoft.Azure.Management.WebSites.Models.VirtualApplication
$virtApp.VirtualPath = $VirtualPath
$virtApp.PhysicalPath = $PhysicalPath
$virtApp.PreloadEnabled = $PreloadEnabled
foreach ($path in $webApp.SiteConfig.VirtualApplications.VirtualPath) {
$existingPaths += @($path)
}
if ($existingPaths.Contains($virtApp.VirtualPath)) {
Write-Host "Virtual path already exists"
}
else {
$webApp.siteconfig.VirtualApplications.Add($virtApp)
Set-AzWebApp -WebApp $webApp
}
}
Then I call it with:
Set-WebAppVirtualDirectory -Branch "mymasterbranch" -Environment "dev" -Product "thiscoolproduct" -VirtualPath "/thepath" -PhysicalPath "site\wwwroot\yourwebpage"
Any update on this issue ? Any plans to support path mappings ?
Here is a non-PowerShell way to do it on creation only by adding it to the azurerm_app_service resource as a provisioner:
# https://docs.microsoft.com/en-us/azure/app-service/configure-connect-to-azure-storage?pivots=container-windows
# az webapp config storage-account add --resource-group <group-name> --name <app-name> --custom-id <custom-id> --storage-type AzureFiles --share-name <share-name> --account-name <storage-account-name> --access-key "<access-key>" --mount-path <mount-path-directory of form c:<directory name> >
# az webapp config storage-account list --resource-group <resource-group> --name <app-name>
provisioner "local-exec" {
command = "az webapp config storage-account add --resource-group ${self.resource_group_name} --name ${self.name} --custom-id archive --storage-type AzureFiles --share-name ${azurerm_storage_share.share.name} --account-name ${azurerm_storage_account.storage_account.name} --access-key ${azurerm_storage_account.storage_account.primary_access_key} --mount-path \\path\\to\\folder"
}
If it is a Linux path, change the --mount-path
parameter to something like /path/to/folder
Is there any progress on this "bug" (or should we call it feature request)? I'm also have to solve this in an alternative way now - not optimal when Terraform has been chosen for IaC. :)
Can anyone confirm if it's supported in Terraform by now?
Note - I know the workaround and using it from long time hence trying to check if its implemented in Terraform yet.
Hi all. The resource here has been deprecated in 3.x and superseded by azurerm_windows_web_app
and azurerm_linux_web_app
. The former supports the virtual_application
block, which covers the functionality described above. afaik, the Go SDK doesn't support this functionality for Linux apps, but I'll dig into it as soon as I can and chat to the team at MSFT to see what we can do. For now, since this resource is deprecated and feature frozen, I'm going to close out this issue for now.
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
When modifying Path mappings manually on the configuration blade, terraform will not mark the resource as tainted. Also, you are unable to configure these values in the azurerm_app_service block. Virtual path, physical path etc... This is a commonly used configuration in many enterprise applications.
Community Note
Terraform (and AzureRM Provider) Version
Affected Resource(s)
azurerm_XXXXX
Terraform Configuration Files
Debug Output
Panic Output
Expected Behavior
Actual Behavior
Steps to Reproduce
terraform apply
Important Factoids
References
0000