7 Tips for Better Cloud Apps with Azure App Service and More
Microsoft Azure offers robust tools for successful app deployment. Learn about features like Azure App Service, Azure Devtest Lab, and Application Insights.
Dec 9, 2022 • 3 Minute Read
Cloud apps are incredibly popular, and there are a lot of them. When it comes to Azure, I often see small changes that can make Azure environments more robust, efficient, and reliable. Below, I’ll walk you through my top seven tips to do so.
Catch my 7 Tips for Building Robust Cloud Applications webinar, where I break down these suggestions in less than 20 minutes:
Protect against accidental deployment in Azure App Service
The first tip relates to Azure App Services, and deployment slots in particular. As we know, friends don’t let friends deploy to production. But sometimes it’s still a little bit hard. Microsoft Azure makes it a lot easier. We know we want to eliminate accidental deployments and provide a production-like QA. That way, the environment we deploy to production is as close to production as it can be. That’s what Azure App Service deployment slots are for.
How to set up Azure App Service deployment slots:
In the Azure portal, find the Azure App Service
Click on “Deployment Slot”
Click on “Add Slot”
Name it (e.g. “Staging”)
You’ll notice underneath the slot is getting a unique URL so you can target it specifically. You can also choose to clone settings from your main slot.
Now, you’ve created a staging slot. It’s exactly like the production slot in every way, but you can deploy directly to it. When your staging is ready for production, simply click “Swap.” With no downtime, you’ve published your staging code to production. The slots have the same names, but the code changes. That’s all it takes to use deployment slots for a more streamlined deployment flow.
Use Azure App Service with A/B testing
The second tip is to use Azure App Services and deployment slots for A/B testing. The results from these tests can inform future strategies, but aren’t always easy to set up or manage because you have to set up two different environments and load traffic one way or another.
How to set up and run A/B tests inside Azure
To start, you need two different deployment slots. One will have one type of production version (such as a blue button), and the other will have the other type (such as a red button). To send some traffic to one and some to the other:
Change the traffic number in the deployment slots under “Traffic %”
Verify the system automatically changed the other slot to add up to 100
Develop your Azure skills with on-demand courses and hands-on labs to better plan, implement and manage Azure environments.
Safer testing with DevTest Labs
Tip number three is about testing infrastructure. When you let developers create their own testing environment, they spin up a Virtual Machine (VM), create an app service, or set up Docker containers. But they’re human, and humans are forgetful. They also don’t always follow company policy. The issue is, any misstep in this process could lead to cost blowouts. Like, for example, if your developer creates a VM and forgets about it, so it just sits there spinning. This is where DevTest Labs come into play.
DevTest Lab is a way to manage a lot of resources, mainly virtual machines and disks. Each individual user has their own dashboard when they log into Azure.
How to use DevTest Labs in Azure
Click on your virtual machine
On the left-hand side, you’ll see claimable virtual machines
Click on the unclaimed machine’s name and claim it
Once you’ve claimed it, it’s yours to use. But because these are shared virtual machines, you can unclaim the VM if someone else needs to use the virtual machine after you. Then they can claim it to do their testing. You can also use your own custom images for these virtual machines, meaning you could have your own environment on them.
If you want another virtual machine and it is allowed in the policy, click “Base.” From there, you can choose one to use in your DevTest Lab. This is a good way to organize your resources in a common way. Many developers can use the same resources, and you won’t suddenly have orphaned resources or resources that shouldn't be created in the first place.
Want more tips on Azure? Check out our Ask the Expert guide.
Rely on Azure Function Testing
Azure functions are the darling of the serverless world, but serverless testing often seems difficult. After all, it's someone else's server. How would we know how to test someone else's server? Remember: Functions are just code, and we can test that.
How to run Visual Studio tests on Azure Functions:
Open Visual Studio
Click on “Test,” then “Test Explorer”
Run all those tests by clicking the start button
These tests are run locally, so there’s no need to connect to Azure. On the right side of the Test Explorer, you’ll see whether the tests passed or not. This is a simple way to create tests for functions, and it makes your life much easier and robust.
Get a variety of Application Insights
With our cloud apps and sites, there may come a time when we say, “Oh no, what went wrong?” Tracking down the cause of issues within Azure can be tricky because, though we may have our own performance or debugging tools, we can’t install them. Application Insights help us figure out any performance issues around these services on Azure.
Application Insights is a part of Azure Monitor, and it lets you drill into any web app on Azure that is enabled for. So, you’ll get an instance of application insight for each service that you enable it for.
Using Application Insights
Within the application map, you can see how many calls are going into a site. You can also drill further down into the information provided. Application Insights also provides performance metrics for any given site that you can dig into to improve your site.
There are other features in Application Insight, such as Smart Detection. This AI-based detection learns about the application so it knows what's normal and can detect things that aren't. Live metrics lets you see what's coming in and what’s going out.
Monitor and tune your app’s performance
The sixth tip is about performance for cloud apps and sites. As we know, websites have to be fast. If they're slow, they tend to die because people lose patience. But you don’t always know immediately if your website starts slowing down. You need database performance tuning and monitoring for cloud apps to help identify slow downs.
One way to do this in Azure is with Query Performance Insight, which is a tool that allows you to:
Drill down into details of a query
View the query text
View the history of the resource utilization
With Query Performance Insight you’re able to slice and dice all the queries on the database that have been performed. That way, you can figure out what isn't working properly, and you can fix it.
Learn best practices for architecture
Architecture can be hard. It’s not always that simple to build up an infrastructure in the cloud. Don’t be afraid to use the best practice documentation Microsoft has. I know there’s a lot of it, and sometimes it’s difficult to determine if the best practice is actually best for your organization. But the suggested architectures for IaaS, PaaS, and microservices are great templates anyone can use when developing inside Azure.
These best practice templates include development, testing and production elements, as well as how data flows through that organization. This is a good starting point for organizations looking to create or optimize their Azure infrastructure.