Azure App Service Environment - New-AzureRmWebApp broken? - azure

I have been developing deployment scripts to create and automate Azure Web Apps and those are working well.
Today I am trying to move these into an App Service Environment in preparation for production.
I find out that the command used for creating Web Apps doesn't work with an ASE.
New-AzureRmWebApp -ResourceGroupName $ResourceGroupName -Name $SiteName -Location $location -AppServicePlan $AppServicePlan
New-AzureRmWebApp : Server farm with name ASE01 not found.
However when I view in Azure Resource Explorer I can see that the 'Server Farm' is there, along with the normal Web App Service Plans.
Microsoft.Web/serverfarms/ASE01
It's extremely frustrating to spend weeks developing scripts to automate stuff and then find that the App Service Plan simply does not interface with these scripts.
Anyone have any ideas on how I can move forward?

James,
To create WebApps in ASE you need to use the following command
New-AzureRmWebApp -ResourceGroupName WebAppResourceGroup -Name webappname -Location "North Central US" -AppServicePlan WebApp-AppServicePlan -ASEName ASEName -ASEResourceGroupName ASEResourceGroupName
Note that the location parameter is required though not used - just need to be a valid Azure location.

Related

Azure Cloud Services Extended Support Deploy using New-AzCloudService powershell. Set swappable cloud service

Few days ago I moved my service from Azure Cloud Services classic to Cloud Services extended support. The latest doesn't have Production/Staging slots. There is a new swap mechanism that is activated if during a deploy we configured the "swappable cloud service". I can do it using Visual Studio publish magic and it works fine.
Now I want to make a deploy using powershell script. The code below just creates a new deploy without activated swap. It works fine.
New-AzCloudService -Name $stagingName `
-ResourceGroupName $resourceGroupName `
-Location $location `
-ConfigurationFile $cscfgFilePath `
-DefinitionFile $csdefFilePath `
-PackageFile $cspkgFilePath `
-StorageAccount $storageAccount `
-KeyVaultName $keyVaultName
I didn't find any samples or clues of how to add the "swappable cloud service" to the New-AzCloudService. I figured out there is such settings in
NetworkProfile.SwappableCloudService.Id but I can't understand how to set it up properly. For example, if I add:
$production= Get-AzCloudService -ResourceGroup $resourceGroupName -CloudServiceName $productionName
$production.NetworkProfile.SwappableCloudService.Id = $production.Name # just to reuse the object
$loadBalancerConfig = CreateLoadBalancerConfig
$networkProfile = #{loadBalancerConfiguration = $loadBalancerConfig; swappableCloudService = $production.NetworkProfile.SwappableCloudService }
New-AzCloudService -Name $stagingName `
...
-NetworkProfile $networkProfile `
I got the error:
New-AzCloudService : Parameter set cannot be resolved using the specified named parameters
Is it possible to set the "swappable cloud service" for New-AzCloudService? How to do it?
Is it possible to set the "swappable cloud service" after the deploy (in any way, Azure portal, API, powershell, etc.)?
I suspect the issue relates to the -NetworkProfile not being supported when -ConfigurationFile, -DefinitionFile, and -PackageFile are used.
In the documentation, -NetworkProfile is used with -PackageUrl and -Configuration instead.
I've asked Microsoft about this as I am having the same issue.
Try $production.Id instead of $production.Name. Or $production.id (I am not sure if the case is important).

how to fix 'conflicts with an already existing hostname' while cloning web app using Azure cloudshell

Scenario: You want to clone an app to another region, while configuring an Azure Resource Manager traffic manager profile that includes both apps.
Below are the commands I tried
$srcapp = Get-AzWebApp -ResourceGroupName SourceAzureResourceGroup -Name
source-webapp
$destapp = New-AzWebApp -ResourceGroupName DestinationAzureResourceGroup -Name dest-webapp -Location "South Central US" -AppServicePlan DestinationAppServicePlan -SourceWebApp $srcapp -TrafficManagerProfileName newTrafficManagerProfile
the above commands fail with ""Creating app with backup from 'subscriptiondetailshere' failed: Detail: Hostname \'abc.xyz.companydomain.com\' conflicts with an already existing hostname. ExtendedCode: 04005"
FYI : the apps are hosted in standard app service plan. I did read documentation saying only the premium apps can be cloned but I was able to clone this particular app in standard plan through Azure Portal UI.
I want to be able to automate this using the ps. Any pointers are appreciated
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-app-cloning
Update:
copied web app:
Traffic manager:
First, azure web app clone does support standard app service plan. Here is a screenshot from the doc:
Second, the code you're using is correct, I did a test at my side, it's working fine(The web app is copied from central us to west us, after copied, everything is working fine):
For the conflicting error, you should check in your destination resource group if there is a existing web app with that host name(you mentioned that you can copy from azure portal, maybe you didn't delete it when you were using code to copy it).

Azure - Move an webapp to an another appservice plan - Powershell

Hi is there a powershell script for moving a web app to an another app service plan who is not in the same resourcegroup. Or can we create a web app where the app service plan is not in the same resource group.
New-AzWebApp -ResourceGroupName $WebAppResourceGroup -Name $testWebAppName -location $location `
-AppServicePlan $appServicePlan01
This script create a new webapp and a new app service plan even there is one exist with the same name. so in case when a want to move the problem resiste the same i cant move it to an existing app service plan.
Set-AzWebApp -Name $WebAppName -ResourceGroupName $WebAppResourceGroup `
-AppServicePlan $appServicePlan02
is there a powershell cmdlet for doing this or do I move the webapp trough the portal.
Thanks
The region in which your app runs is the region of the App Service plan it's in. However, you cannot change an App Service plan's region. If you want to run your app in a different region, one alternative is app cloning. Cloning makes a copy of your app in a new or existing App Service plan in any region.
It can be accomplished by using the Azure Resource Manager version of the PowerShell cmdlet to create a new app with the -SourceWebApp option.
https://learn.microsoft.com/en-us/azure/app-service/app-service-web-app-cloning#cloning-an-existing-app

Azure ARM Scale Set - deploy and update solution

I have been browsing web regarding Azure Scale Set service and I have been able to find a lot of resources connected to scaling and deploying of scale set, however I was not able to find any information regarding deployment and update of the solutions deployed to the machines within scale set. Please what is the best practise when I want to host e.g. a web solution within scale set? How should I perform deployment and updates?
Thank you in advance.
It will depend on how you configure the scale set to be a web solution to begin with...
For example, if you create the VMSS with a template and then configured the VMSS with a custom script extension, then you could run the template deployment again and update the script.
If you used DSC (windows vm) then you could just update the artifacts source and DSC will do the update while the VMs are running.
If you want to use PowerShell for deployment to the Scale Set.
$customConfig = #{
"fileUris" = #("https://$storageAccountName.blob.core.windows.net/scripts/script.ps1");
"commandToExecute" = "PowerShell -ExecutionPolicy Unrestricted .\script.ps1";
};
$vmss = Get-AzureRmVmss -ResourceGroupName $resourceGroup -VMScaleSetName $vmssname
Add-AzureRmVmssExtension -VirtualMachineScaleSet $vmss -Publisher Microsoft.Compute -Type CustomScriptExtension -TypeHandlerVersion 2.0 -Name "runscript" -Setting $customConfig
# Send the new config to Azure
Update-AzureRmVmss -ResourceGroupName $resourceGroup -Name "$vmssname" -VirtualMachineScaleSet $vmss

Move Azure website between App Service Plans

Is it possible to move an Azure Website to a different (or new) App Service Plan?
I have already tried both the old and new portals but cannot find the options for this.
The original accepted answer is more than a year old. In Azure world, that's an eternity. The "Change App Plan" button in the Azure Portal is no longer present it appears (as of 2016-06-17), so I'm throwing in the Powershell command I needed to use in order to move a Webapp to another App Service Plan.
Set-AzureRmWebApp -Name <webapp name> -ResourceGroupName <resource group name> -AppServicePlan <new app service plan>
Set-AzureRmWebAppSlot -Name <webapp name> -Slot <slot name> -ResourceGroupName <resource group name> -AppServicePlan <new app service plan>
The option "Change App Service plan" has been moved to the APP SERVICE PLAN menu.
Yes, you can do this from the Web app blade in the Azure portal. You have to expand the toolbar though to see the option. See below.
I needed to move things between different subscriptions, which is quite possible according to documentation. Much is shamelessly copied from the azure website. This solution is taking advantage of the Azure Powershell 1.0.
First off, if you need to move a Web app and it's connected webfarm there are some limitations:
You can move Azure Web App resources using the ARM Move Resources Api.
Azure Web Apps currently supports the following move scenarios:
Moving the entire contents of a resource group (web apps, app service plans, and certificates) to another resource group.
Note: The destination resource group can not contain any Microsoft.Web resources in this scenario
Moving individual web apps to a different resource group, while still hosting them in their current app service plan (the app service
plan stays in the old resource group)
Basically you need to get the resource id from the resources you want to move and use the Move-AzureRmResource command. You'll naturally need an Azure login which is able to read and write to the subscriptions involved.
$webapp = Get-AzureRmResource -ResourceGroupName OldGroup -ResourceName WebApp -ResourceType Microsoft.Web/sites
$plan = Get-AzureRmResource -ResourceGroupName OldGroup -ResourceName Plan -ResourceType Microsoft.Web/serverFarms
Move-AzureRmResource -DestinationResourceGroupName NewGroup -ResourceId ($webapp.ResourceId, $plan.ResourceId) -DestinationSubscriptionId xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
I'd point out that if you're moving the resources to another subscription, there are some caveats. First, that subscription must have rights to provision the website in that region, the API's for that are beyond this scope, but simply creating a website and removing it will give the subscription those rights. In my case i had a second error which is still unresolved, but i suspect that other resources that are connected to the resources being moved are the culprits. Will update with further information if i resolve the issue.
As a final note, there is also the possibility to use the REST API.

Resources