Is there a REST API call to create a new deployment slot in Azure website?
I am not able to find anything here.
You can do this using the Azure PowerShell cmdlets. For example, I tested this with a site named "cloudallocweb" in East US and then used the following command to create a new deployment slot in the cloudallocweb site.
New-AzureWebsite -Name "cloudallocweb" -Location "East US" -Slot "test"
Peeking into what the New-AzureWebsite cmdlet is doing in the command above, I found this POST operation which is basically the Create a web site REST API. Notice that it is passing the WebSpace setting (matching in the URL), which I don't see documented in the REST API.
At any rate, it appears the Create a Web Site REST API is what you need. This makes sense considering that a deployment slot is really just a web site. You may also take a look at the List Webspaces API to find the right web space value for your site.
Following the steps above, the new deployment slot will appear under the original site as shown here. You can then swap the deployment slots using the portal, REST API, or the Switch-AzureWebsiteSlot cmdlet.
Related
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).
I have an ARM Template stored in Azure Templates.
Is there a way to reference this template from script (either in Azure Cloud Shell or PowerShell/CLI on local machine)? Right now it seems the only way to deploy the template is through the Azure portal UI.
Update
I wanted to clarify what I am asking. I am asking specifically about Azure Templates (Preview) service. It seems that once you store a template in Templates service the only way to access it is through the Azure portal.
For example, let's say I am creating a VM in Azure portal. I can save the ARM template to Templates service as shown in the images below.
You can click on Download Template and parameters link, on next page click on Add to library to save the template to Templates service (Templates service can be found in Azure portal through All Service > filter for "Templates").
I was doing the course on edX.org: Automating Azure Workloads and it was talking about this service, that's why I became interested in this service.
You can deploy a template with every possible mean you mention. Not only the portal UI.
There is documentation here - section Deploy a template from external reosurce (also explains how to deploy from a private resource using SAS:
New-AzureRmResourceGroupDeployment -Name ExampleDeployment -ResourceGroupName ExampleResourceGroup `
-TemplateUri https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/101-storage-account-create/azuredeploy.json `
-storageAccountType Standard_GRS
The referenced documentation also provides sample for use with Cloud Shell.
I have uploaded an SSl certificate on the azure portal for my web app.
Is there a way to add key-value tag for the cert? From the documentation, I see tags only for resource-group etc but not for a particular cert.
If you are able to see the certificate in your resource group, just add tag as usual.
On my side, the certificate is hidden because it's managed by Azure. I can show it by clicking the checkbox on top of your resource group.
If after you click the certificate and there is no Tags bar on its panel, you can choose to use cloud shell to add tag. You can find the cloud shell on top right of your portal.
The first time you run it, you may need to create storage for the shell, just follow the steps azure provides. Then we can add tags. Use powershell script as an example, just two commands to achieve your goal.
$r = Get-AzureRmResource -ResourceName certificatename -ResourceGroupName resourcegroupname
Set-AzureRmResource -Tag #{ TagName="TagValue"} -ResourceId $r.ResourceId -Force
Things work on my side. Any further question, just ask.
Looking at the REST API documentation for Create or Update Certificate, looks like it is possible to assign tags to SSL Certificates. I believe this functionality is not exposed on the Portal. I looked up Azure Powershell Cmdlets as well and couldn't find anything there (it is entirely possible that I may have missed out something).
If you need to assign tags to SSL Certificate, you can always use REST API and invoke that API using either writing code or using a tool like Postman. Other thing you should look at is Azure SDK. In all likelihood, you will find some functionality there which will let you assign tags to a SSL certificate.
I was able to add a custom domain to a Azure deployment slot on one web app, but when I tried to add one to another, I keep getting:
The resource 'Microsoft.Web/sites/xxx(xxxx)' under resource group 'Default-Web-WestEurope' was not found
*Where xxx(xxxx) is my web app name and deployment slot.
I've tried to remake the deployment slot, I've recreated the web app but still no luck.
I managed to solve this by using the Azure Powershell using the following command:
Set-AzureWebsite -Name "xxx(xxxx)" -HostNames #('custom.domain.com')
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.