Open tjrobinson opened 6 years ago
I can't comment on how likely this feature is to make it in. But do note that it is possible to install site extensions today using the low level PowerShell Azure Resource CmdLets. Full sample helpers here.
@davidebbo Thanks that's just what I need! It'd be great to get first class support for it but in the meantime I can use what you've linked to.
For the benefit of others, I've knocked up a quick standalone module:
# Based on https://github.com/davidebbo/AzureWebsitesSamples/blob/b566c5bcf2ad3c3783b70d0082a4fc83809181f4/PowerShell/HelperFunctions.ps1#L445-L469
$WebAppApiVersion = "2018-02-01"
Function GetResourceTypeAndName($SiteName, $Slot)
{
$ResourceType = "Microsoft.Web/sites"
$ResourceName = $SiteName
if ($Slot) {
$ResourceType = "$($ResourceType)/slots"
$ResourceName = "$($ResourceName)/$($Slot)"
}
$ResourceType,$ResourceName
}
# Example call: ListWebAppSiteExtensions MyResourceGroup MySite
Function ListWebAppSiteExtensions($ResourceGroupName, $SiteName, $Slot)
{
$ResourceType,$ResourceName = GetResourceTypeAndName $SiteName $Slot
Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType $ResourceType/siteextensions -Name $ResourceName -ApiVersion $WebAppApiVersion
}
# Example call: InstallSiteExtension MyResourceGroup MySite filecounter
Function InstallSiteExtension($ResourceGroupName, $SiteName, $Name, $Slot)
{
$ResourceType,$ResourceName = GetResourceTypeAndName $SiteName $Slot
New-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType $ResourceType/siteextensions -Name $ResourceName/$Name -PropertyObject @{} -ApiVersion $WebAppApiVersion -Force
}
# Example call: UninstallSiteExtension MyResourceGroup MySite filecounter
Function UninstallSiteExtension($ResourceGroupName, $SiteName, $Name, $Slot)
{
$ResourceType,$ResourceName = GetResourceTypeAndName $SiteName $Slot
Remove-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType $ResourceType/siteextensions -Name $ResourceName/$Name -ApiVersion $WebAppApiVersion -Force
}
Example usage:
param(
[Parameter(Mandatory=$true)][string]$resourceGroupName,
[Parameter(Mandatory=$true)][string]$extensionName
)
Import-Module .\SiteExtensions.psm1
$webApps = Get-AzureRmWebApp -ResourceGroupName $resourceGroupName
foreach($webApp in $webApps) {
"Installing $extensionName into $($webApp.Name)"
InstallSiteExtension $resourceGroupName $webApp.Name extensionName
}
@panchagnula @ahmedelnably Can you take a look at @tjrobinson's proposal?
We do want to support site extensions, however, there is no ETA on this support from our end as yet.
@btardif will sync with you on the commandlet design for this.
We are currently evaluating options for this request.
this might be covered by #9342 but we need to validate the scenario once this cmdlets are available.
with the work in #9342 the following will be enabled
Get-AzWebAppSiteExtension Get-AzWebAppSiteExtensionSlot Install-AzWebAppSiteExtension Install-AzWebAppSiteExtensionSlot Remove-AzWebAppSiteExtension Remove-AzWebAppSiteExtensionSlot
@panchagnula Thanks. Do you have any idea when these commands will be publicly available?
@panchagnula I can see that Az.AppService
4.0.2-preview
now has these commands but I received a 400 Bad Request when using them. Is there an ETA for V4 to be out of preview?
https://www.powershellgallery.com/packages?q=Cmdlets%3A%22Install-AzWebAppSiteExtension%22
See also: https://github.com/Azure/azure-rest-api-specs/issues/2819
Hi Is there a command let to install extension to web app and function app ?
with the work in #9342 the following will be enabled
Get-AzWebAppSiteExtension Get-AzWebAppSiteExtensionSlot Install-AzWebAppSiteExtension Install-AzWebAppSiteExtensionSlot Remove-AzWebAppSiteExtension Remove-AzWebAppSiteExtensionSlot
cant find it. do these exists?
Background
It's not currently possible to use either Azure PowerShell, or Azure CLI, to add/remove Azure Site Extensions. It can only be done using ARM templates, the REST API (steep learning curves for beginners, see below) or manually through the Azure Portal. I would like it to be easily scriptable alongside existing CLI or PowerShell scripts I use, including in Azure Cloud Shell.
Proposed Solution
Add the following commands:
Where
Name
would be the name of the nuget package, e.g.RemoveCustomHeaders
(https://www.nuget.org/packages/RemoveCustomHeaders).The
New
command could also update to either the latest version, or the specified version if already installed?Alternatives
It's possible to configure Site Extensions using ARM templates but unless you are already using ARM templates, it's potentially a lot of work to get set up, especially for beginners: https://developer.rackspace.com/blog/Azure-WebApp-Extensions-with-ARM/
It's possible to call the Kudu REST API directly, though as you can see from this blog post, it's not straightforward: http://poshdb.com/home/install-azure-app-extension-powershell/
Additional context
Documentation on what Azure Site Extensions are: https://github.com/projectkudu/kudu/wiki/Azure-Site-Extensions
Blog post describing how to install and manage extensions via the Azure Portal: https://www.michaelcrump.net/azure-tips-and-tricks21/
Note that all Site Extensions are hosted on NuGet, with a tag of
AzureSiteExtension
: https://www.nuget.org/packages?q=Tags%3A%22AzureSiteExtension%22Copying in @davidebbo (Dev manager on Azure Functions and Azure App Service).
I have raised a similar feature request for the Azure CLI here: https://github.com/Azure/azure-cli/issues/7617
Thanks.