Automatic azure deployment - c#

We've developed a MVC application that uses a SQL database to store data. We chose the approach to have a separate web app in azure (customer.ourdomain.com) per customer, as well as a separate database per customer running on our SQL server. This database is pointed to by the MVC application in the web.config file.
I've also created a website where new customers can register to use / try our product. Now every time somebody registers for our product I want the following to happen:
Create an Azure web app with the name of the company / customer that registers
Create a new database including the tables and relationships that our application needs
Publish the stable release of our application to the web app in azure and configure the application to use the newly created database
I've managed to do the first step using Azure ARM templates and the second step using dacpac and the Azure API, but I don't know how to use TFS (or any other method) to publish a stable release and change the connection strings before publishing the application to the azure app. (I've not even managed to publish anything with C# code).
Is the approach I'm taking in general okay or should I take a different approach? What is the best way to publish a stable release to the web app and most importantly, change the connection string so the published version will connect to the new database?

If you get vsts to package up your stable release and upload it to blob storage, you can reference that web app as part of the ARM template deployment, ie. include the web app code deployment along with the web app service itself.
This page shows how it can be done. I think you can also get the web app and ARM template to pull a release from vsts (I'm pretty confident you can do it via GitHub) using the app service's source control integration/CD settings as well, but cant find any details on this.

Related

ASP.Net WebSite not visible after deploying in Azure web app through CICD pipeline

I have deployed my ASP.Net web app application in the Azure web app through the CICD pipeline. Deployment gets succeeded. But, on opening mywebapp.azurewebsites.net, it is showing
Hey, App Service developers!
Your app service is up and running. Time to take the next step and
deploy your code.
What mistake I am doing?
I would recommend a way to troubleshoot any app service deployments as follows.
Go to the Advanced tools left menu item on Azure app service as shown below
You will be taken to a website like the below. Follow the highlighted menu item as shown below to see the file system where you deployed your application.
3. Make sure your application files are there in the expected directory structure within wwwroot folder. If not, then you have not setup your CICD pipeline correctly. Make adjustments to your build and release pipeline accordingly. Follow the latest resource on here . Let me know you need further guidance.
If you use one of these:
WebApp on Windows
Function App on Windows
API App
Mobile App
you may try marking flag removeAdditionalFilesFlag
More details you can find in the codumentation here.
If you don't use one of above mentioned types you can consider this task - Azure WebApp Virtual File System Tasks.
I recommend you to try it out as it looks that original index file is still in place. This is why yoy may not see your page.

Azure - can't create a new web app on an existing service plan

Hello,
I have a "Basic" App Service plan on Azure.
Issue: I cannot create a new web app on an existing App Service Plan.
It only gives the option of creating a new app services plan (but I don't want another app service plan). No errors. No explanations. Just options for "new" app service plans.
It used to be a case of create new web app -> select service plan -> choose existing -> select from existing app service plan -> create a web app. Done.
I am trying to create a new web app - there is now a new interface to achieve this - however, when I select a resource group, same region as App Service Plan, there is only the option to "create new app service plan" - but I already have one - it's not appearing in the list.
Things I have tried:
Looking at resources - memory usage is approx 60-70% - so it doesn't appear to be that. I even removed a website that was stopped just in case.
Logging out and back in
Logging in as original administrator on another PC (not delegated admin as I am).
Removing an existing web app
Go through each resource to find a combination that will unveil my app service.
I have both web apps and functions (.net core C#) - can it be something to do with having functions and windows web apps .net core c# working on the same web service?
What am I missing? I feel it is something obvious.
Thanks.
I had the same problem. I had App Service Plan located in West Europe.
Then, I wanted to add an App also to the West Europe, however the resource group that I selected for this app was located in North Europe. When I changed resource group that was located in West Europe problem was solved.
As mentioned in the other answer ASP and Function app needs to be in the same location.
In addition to that, in my case the existing App Service Plan turned out to be an ASP that was created for Consumption Plan (Y1).
So, if I need to reuse that ASP, my new function has to use consumption plan.
But, when creating a new function, I did not see anything in the azure portal that allows to pick an existing ASP when selecting consumption plan.
I was able to work around this by generating the ARM template instead of directly creating the resource in portal. i.e. in the "Review + Create" screen, i would hit "Download a template for automation"
Then hit deploy, and in the deployment screen, i would update the parameter for the hostingPlan name, and change it to the existing ASP:
This will create the function in an existing consumption plan ASP.
Credit to this answer that pointed me in the right direction
Its something wrong with browser. Try MS Edge instead of Chrome or whatever. Faced agains same issue. In MS Edge it worked

Is there an easy way to replace Azure Cloud Service reference dll without re-publishing the service?

I have an Azure Worker Role running in a Cloud Service. The worker is a wrapper around my custom library which runs code. When I make a change to my library I'd like to simple replace the old with the new. Currently I have to republish the entire Cloud Service project which takes time and seems like a wasted effort. I understand it might be necessary when I have multiple instances or other issues, but for now I'd like to simply copy my new dll to the service instead of publishing the entire project.
Is this possible?
After reading the documentation linked to by Ralf I found this:
If your app’s backend infrastructure is stable, but the web roles need
more frequent updating, you can use Web Deploy to update only a web
role in your project. This is handy when you don’t want to rebuild and
redeploy the backend worker roles, or if you have multiple web roles
and you want to update only one of the web roles.
later it restates :
Only web roles can be updated: Worker roles can’t be updated. In
addition, you can’t update the RoleEntryPoint in web role.cs.
For anyone wanting to update a web role this nugget is very important to remember:
The changes are made directly to the virtual machine where the web
role is running. If this virtual machine has to be recycled, the
changes are lost because the original package that you published is
used to recreate the virtual machine for the role. You must republish
your application to get the latest changes for the web role.
When you are developing and testing an Azure application, you can use Web Deploy to publish changes incrementally for your web roles.
More info:
https://msdn.microsoft.com/en-us/library/azure/ff683672.aspx
For webrole Web deployment could incrementally add the new file. If you Want not to enable web deploy you need to have remote Access enabled for the role, then you can connect to the instance and replace the .dll file.
Depending on the role you'll need to find IIS folder (in case of Webrole) or access "%ROLEROOT%\AppRoot" (in case of Worker Role).
You could need to restart the IIS instance in web role scenario. For worker role you'll need to kill WaWorkerHost, it will be restarted automatically

How do I deploy an app with multiple components to Azure?

So my application is composed of a handful of separate .NET components that all run in Azure. To give you an idea of what's involved:
A main ASP.NET MVC5/Web API 2 REST service that runs as an Azure website (I think they renamed these to web apps?).
A SQL database that the main REST service uses.
Another internal Web API REST service that the main REST service talks to that runs as an Azure website.
An Azure storage table that the the internal Web API REST service uses.
3 scheduled jobs (just .NET exe's) that do work in the background and also talk to the main SQL database.
All that's running great in Azure right now. My problem is automating the deployment and configuration.
Right now it's all manual. I right-click and publish both web apps from Visual Studio. I build and FTP up the web jobs. The database and Azure storage already exist so I don't have to re-set them up.
But say something bad happens - a datacenter goes down or something. I'd like to be able spin up a new version of my app (with all those components) that is ready to go with minimal effort.
I'm pretty new to the world of Azure so I'm not sure where to start. What are my options?
You are looking to automating deployments in Azure. I recommend to use ElasticBox to solve it.
To achieve the automation you will need to create a box for every different service or component you need to deploy (a box is the abstraction unit that uses to define the installation and configuration of the deployment of a service or application in any cloud).
It's possible also to create boxes based on VM Instances, VM Roles, or Worker Roles and also automate the deploy of Microsoft SQL Servers. Let's say near every option offered by Azure.
Then with those boxes completed (that can be customized and reuse your legacy code from your previous manual installation), you can deploy the multiple vms with near no manual intervention, just one click or a command with some parameters.
A box includes the variables necessary for your deployment (you can set default values for those variables) and your legacy scripts (In this case probably PowerShell, but they could be bash, python, perl, java, or any other language)
When you deploy your boxes:
Creates a Cloud Service or VM in the location that you choose and with the Azure configuration that you preconfigured. It takes care of provision the vm in your Azure provider, or near any other cloud provider in the market.
Installs, configure files with your specified variables and execute your SQL or Web services that you have defined.
Other ways to interact with the service:
Jenkins' Plugin could be used to build a CI environment connecting your code updated or a Pull Request with automated deployments in Azure or any other public cloud.
Command line tool that enables to do VM deployments of your boxes and also you can manage your deployed vm instances with it.
Azure Resource Manager (ARM) is intended to solve exactly the issues you described.
The basic idea is that you use a JSON template to describe all your services. You can then give that template to ARM and it will create the services as defined in the template. If you want to make a change, instead of doing it imperatively (via powershell or manually in the portal) just update your template, pass it to ARM and it will make whatever changes are necessary to make the services match your template.
Some resources:
ARM talk at MS Ignite 2015
ARM template language reference
Quickstart templates on GitHub
Azure Resource Explorer - view ARM templates of existing resources
Resource Group Deployment Projects in Visual Studio
I think your looking for something to help you handel deploys to your windows Azure servers. If that is the case I recommend looking into Jenkins CI. There are many resources available online you can look into in terms of having Jenkins and Azure work together.

HTML5 with .NET backend App, compatible with both standalone Windows and Azure?

I need to design an HTML 5 responsive, and simple app that should work on both internal Win server and on Azure.Our Client wants to check out Azure but maybe later he will want this app to be on its own on premise servers. Our Developers are almost all .NET back ends, with basic knowledge in HTML 5, Javascript, Jquery, and bootstrap. We accepted the challenge because the project is tiny and interesting, the point is, is possible to have 1 project that can be deployed to azure or IIS with no problem? and what kind of project should we create? I think that a simple asp.net project with some web methods and js will do the job, but I don't know if it will work on azure too. Back n 2010 I did something that way but now I am not sure it's still valid
Important: the web application should be able to query oracle on premise server, via web service but not sure if take azure service bus or azure vpn
It depends on how you build your application. I have built applications in the past that works both on-premise and on Azure. As long as you don't access any Azure specific features, there's no problem to deploying the web application project to an on-premise IIS.
If you use Azure-specific features or services from Azure, such as Azure SQL DB, you have to built an on-premise version. In my case it was simple as changing the connection string and the rest was done by Entity Framework, but you can use an IoC container, such as Unity, to change your implementation based on the environment you're running on. If the Azure environment is available (check through RoleEnvironment.IsAvailable) you resolve the Azure-specific implementation of some features and if not the on-premise implementation. In most cases that are just a few dependencies, for example if you use a worker role on Azure and a Windows Service on-premise.

Categories

Resources