I want to deploy my Azure web apps using PowerShell. Here is my expected workflow:
Create Package using MSBuild
Deploy the package to Azure
I tried with the approach described in the below link:
https://github.com/gregpakes/DoIHaveGPS/blob/master/PublishScripts/Publish-WebApplication.ps1
I modified the script to use an existing web app instead of creating. So I call something like Get-AzureWebsite -Name $Config.name..
But it never finds the existing app service (web app) due to the subscription issue. I tried so many times to switch the subscription but it's not working. Get-AzureWebsite always keep searching on the old subscription which I don't use anymore.
If I call Get-AzureRmSubscription from powershell I get two subscriptions but if I call Get-AzureSubscription I get only one.
How can I deploy my application packages using powershell using resource manager based powershell?
The cmdlets used by the script you linked to are using the "old" service management interface. If Get-AzureSubscription doesn't return a subscription that means it's only available to use via AzureRM. The AzureRM web app cmdlets don't have a simple "publish" command as the old ones did... So if you wanted to replicate that in PowerShell you could do something like this:
$deploycmd = "$env:ProgramFiles\IIS\Microsoft Web Deploy V3\msdeploy.exe"
$packageLocation = Resolve-Path -Path "C:\users\bjm\downloads\package.zip"
$webAppName = 'myazuresite'
$user = '$myazuresite'
$pass = 'jSjku1lWBdZNgGjyZWYfDhFn4DFfZlAqTq1RjPu5Fnv3yYe9l2Fl5xz5RK0x'
$setParam = "-setParam:name=""IIS Web Application Name"",value=$webAppName"
$dest = "-dest:auto,ComputerName='https://$webAppName.scm.azurewebsites.net:443/msdeploy.axd?site=$webAppName',UserName='$user',Password='$pass',AuthType=Basic"
& $deploycmd "-verb:sync", "-source:package=$packageLocation", $setParam, $dest
I actually prefer juvchan's approach but if you've already got the rest in place via PS this might be easier.
After you've created the web deploy package for your application, you need to create a Azure Resource Manager (ARM) template which allows you to deploy to a Azure web app using the web deploy package.
Then you can use the Azure PowerShell cmdlet below to deploy your ARM template above to achieve what you require.
New-AzureRmResourceGroupDeployment -Name <deployment-name> -ResourceGroupName <resource-group-name> -TemplateUri <ArmTemplateJsonUri>
Useful references:
Deploy a web app with MSDeploy, custom hostname and SSL certificate
Deploy your app to Azure App Service
https://github.com/Microsoft/azure-docs/blob/master/articles/azure-resource-manager/resource-group-template-deploy-cli.md
https://github.com/Microsoft/azure-docs/blob/master/articles/azure-resource-manager/resource-group-template-deploy-cli.md
This topic shows how to use the Azure portal with Azure Resource Manager to deploy your Azure resources. To learn about managing your resources, see Manage Azure resources through portal. Currently, not every service supports the portal or Resource Manager. For those services, you need to use the classic portal. For the status of each service, see Azure portal availability chart.
1. To create an empty resource group, select New > Management > Resource Group.
2. Give it a name and location, and, if necessary, select a subscription. You need to provide a location for the
Related
I have developed a Azure Service Fabric service .Net core 2.2 which contains a controller and some API methods inside it. I deployed the service on local cluster and its working fine. I am able to access the api endpoints.
But now I need to deploy it on local IIS too. I published the service project that contains my controller, and when I try to deploy it on local IIS as we usually do while deployment of other apps, I get an error "HTTP Error 500.0 - ANCM In-Process Handler Load Failure". I am googling for this and trying to find solution but no success yet.
Is there any particular setting or process that needs to be followed to deploy Azure Service Fabric service on IIS ? I am unable to figure out what I am missing.
Any suggestions or ideas?
When you create a Service Fabric service, the runtime need to talk to the Service Fabric System Services at startup. If you deploy it to IIS, it does not have a cluster to talk to.
If you want to make an API flexible to be hosted either on Service Fabric or IIS, you need to decouple the hosting logic from the API.
In this case, you can either create two different hosts, or:
in the host entry point, check if you are running inside SF, if yes you start the Service Fabric Service otherwise you start a self-hosted or IIS version.
There are quite a few questions in SO with examples like this, worth a search to check which one fits your needs.
I am trying to minimize the cost of running my web app in Azure App Service. I have a Visual Studio 2017 solution with two Web Projects: Web and API (both .NET Core). The entire solution is part of a single GitHub Repo. Before adding the API project, the build and deployment to Azure App Service was automated. My goal is to deploy both projects under the same App Service (to minimize cost) with two subdomains (e.g. www.example.com and api.example.com) and keep everything automated.
Is this something that can be done? Can somebody please help me understand how this can be done? Can those settings be commited?
An Azure App Service Plan can contain multiple web apps. Normally when you use the Azure portal to connect it to source control, Kudu (the tool behind App Service Plans), will create a deployment script for that site.
In case you want to deploy two projects of a single solution (and git repo) to different Web Apps you have to do the following:
Create two web apps under the same App Service Plan
Connect both of them to the same git repo for automated deployments
Modify the deployment parameters
I'm going to suppose you know how to do the first two steps.
To modify the deployment parameters, you could either modify the deployment script by downloading it through Kudu and adapting it or, much simpler, configure it through the portal:
Go the App1 => Application Settings => Add setting PROJECT with value
<path>\<path-to-app1>.csproj
Go the App2 => Application Settings => Add setting PROJECT with value <path>\<path-to-app2>.csproj
Every time you push up a change, both web apps will receive an update, but they will deploy a different part to the web site.
More information can be found here (see last paragraph): https://github.com/projectkudu/kudu/wiki/Customizing-deployments
I'm new using ASP.Net MVC, so i'm doing an auto-training in order to develop a web portal for an intranet that can receive request from users to deploy Virtual Machines from Azure, the request is received by an administrator who can run a script from the portal to create the Virtual Machine.
For example, The idea is to store the scripts in a database, so when the administrator do the action to create the "virtual Machine 01" (he have limited option of Virtual Machines configurations to create), the software run the script "01" store on the database.
That is possible? I hope I have explained the idea well.
Also, if that is possible, can I also show the possibles error messages is something wrong happened?.
Instead of using Powershell, why not manage it directly from your .NET code?
Azure provides API's that can be called from .NET.
http://azure.microsoft.com/en-us/documentation/api/
You'd probably want to look at their Compute Management API for handling virtual machines.
http://azure.microsoft.com/en-us/documentation/api/management-compute-sdk-net/
Is there a way I can deploy my entire website/webapp to an Azure WebRole without the need of Visual Studio?
Context: We have a test environment where there's an IIS hosted web app where our testers test (of course). The thing is, we want to grab that exact tested web app folder and deploy it "as is" to a WebRole.
Please avoid commenting on our procedure, we have been looking at it and we will eventually change it if we have to, I just need a 'simple' yes(how)/no answer.
IIS Web Deploy can be used to package/migrate/restore IIS applications. It can be enabled while deploying a web role as described in this article and allows to update the web role with the application as deployed in your test environment.
Be aware that only single instance cloud services are supported and that in case of a maintenance operation by the fabric controller, your service will be rolled back to the state created by the initial azure package deployment. (There once was a tool for syncing between multi-instance web deployments but sadly that did not work out too well and is no longer supported. Do not attempt to use or rebuild it.)
Installing and Configuring Web Deploy shows the steps to get web deploy for your local testing IIS while articles on using web deploy like this one show examples for calling the tool.
Another option to evaluate are azure websites and git deployment. This could provide you with a documented and reproducible form of deployment that is not prone to unwanted rollbacks while allowing the service to scale to multiple instances. This option might not work out if the application it too tied to the web roles infrastructure or contains code not suitable for the more restricted web sites environment.
A third option to look at is using CSPack as presented in this article. You basically create a service definition and package up the webapp manually without building it in Visual Studio or TFS.
Yes - make sure you have enabled Remote Access on your webrole. Then copy your web app from your local IIS folder to F:\sitesroot\0 (NOTE - may be E:\sitesroot\0 on same web roles).
Yes, you can write a programmatic interface against Web Deploy from your C# code. If you're deploying to Azure Web Sites, you could also use the Windows Azure Management Libraries to spin up new web sites or clouand deploy them.
I am creating an application that automate the deployment to Azure Web Sites. I was able to create Azure Web Site, database and storage programmatically but I didn't saw any library out there that can create Azure Cache programmtically. Anyone?
Thanks in advance. :)
Whatever operations you perform on Windows Azure Management Portal is backed by Windows Azure Service Management API. I'm pretty sure that there's an API for creating and configuring caching programmatically but it has not been made public yet. I would recommend keeping an eye out on the REST API documentation page. This is where you will find information about how you could create cache programmatically.
Azure Managed Cache is in preview and hence REST API are not available for it. Also it can not be created from Portal. However, you can use Powershell commands to create it. Once created you can then manage it from azure portal itself.
Following command can be used for creating Basic Cache of 128MB.
New-AzureManagedCache -Name YourCacheName -Location "YourLocation"
For the detailed steps refer to - Create Azure Managed Cache from Powershell
So you can create .ps1 file or powersehll commands string which then can be invoked from your code.
Hope this helps.