Azure Tips and Tricks EN US PDF
Azure Tips and Tricks EN US PDF
azuredev.tips
ISBN 978-1-7327041-2-1
Introduction
Hi, folks!
When I reflect back on Azure Tips and Tricks a year ago, I was only thinking that I’d write
a couple of posts and move on. Fast-forward to today, the collection has grown to over
150+ tips, as well as videos, conference talks, and now an eBook spanning the entire
universe of the Azure platform. What you are currently reading is a special collection of
tips based on page views of the entire series over the last year. I’ve grouped the top tips
and landed on four categories that cover web, data, serverless, and productivity. Before
we dive in, you’ll notice my pixelated form as you turn each page.
These represent:
• Blog - azuredev.tips
• Videos - videos.azuredev.tips
• eBook - ebook.azuredev.tips
• Survey - survey.azuredev.tips
Thanks,
Michael Crump (@mbcrump)
Table of Contents
1 WEB
3 SERVERLESS
2 DATA
4 PRODUCTIVITY
WEB
If you’ve used Azure, you’ve more than likely used Azure App
Service to easily host web applications, REST APIs, and mobile
back ends. In this set of tips, I’ve pulled out the top 6 tips since the
creation of Azure Tips and Tricks for Azure App Service. They include
easily working with files in the console, easily setting up staging
environments and swapping between them, and routing traffic to
different versions of your app to “Test in Production”. I’ll also cover
how you can implement performance testing, best practices for
App Settings in Azure App Service, and cloning a web app that is
especially helpful if you have customers all over the world.
As you can tell from the screenshot, I start in D:\home\site\wwwroot. I can type dir to see a
current directory listing.
I can do basic commands here and even use TYPE <FILENAME> to parse
the output of a file to the screen. You can make directory and so forth, but
keep in mind that this is a sandbox environment and some commands
which require elevated permissions may not work.
Quick Tip You can
type help from the
console window for
a list of available
commands.
A VS Code Experience to an Azure App Service
Great! Now keep in mind that we have two versions of our site:
one that is production and one that is staging. They are identical
except for the staging site has a large font that says jsQuizEngine
version 2.
If you run the application locally, then you’ll see Production as it is coming from the
web.config file, but if you run it inside of Azure, then you’ll see Staging as it is coming
from the Apps Settings configuration store located in Azure. Neat stuff!
Connection Strings vs. App Settings You may have noticed Connection
Strings right below the App Settings option and wonder when to use it. A
general rule of thumb is to use Connection Strings for database connection
strings and App Settings for key/value pair application settings. If you
examine your web.config file, then you’ll see there is also a section for
connectionStrings just as there is a section for appSettings.
Most folks don’t realize how easy it is to configure a backup copy of your
Azure App Service to ensure you have restorable archive copies of your
app and database. In order to take advantage of this, you’ll need to log
into your Azure account and go to your App Service that you created. Look
under Settings and you will see Backup.
Get to work
You’ll need to append the Database name to the end of the string.
For example: Database=bible will be appended to the string
AccountEndpoint=https://mbcrump.documents.azure.com:443/;Account-
Key=VxDEcJblah==;Database=bible that I copied out of the portal.
Now press Verify Connection.
Give it a couple of minutes until you see that it has
completed pulling down your code from Git and then go
to the new URL of your site. You can find the URL on your
overview page. In my case it is, http://myquizapplication-
staging.azurewebsites.net/
Go ahead and open the Azure Portal and navigate to the Azure
Storage account that we worked with earlier.
Look under Settings, then Access Keys and copy the key1.
We can do the reverse and upload a file from our hard disk to
Azure Storage Blob Container with the following command:
The pieces of data that we’d like to extract are the kml, gpx, csv URLs
and the last piece of the Explorer Link URL. After we have the URLs we
are going to download them automatically into a OneDrive folder.
● Filename - This is the general filename that the app uses, and I think
it’s a piece of data we want to store.
● CSV URL - A URL to the CSV File that we’ll be posting to OneDrive.
● GPX URL - A URL to the GPX File that we’ll be posting to OneDrive.
● KML URL - A URL to the KML File that we’ll be posting to OneDrive.
Create JSON Schema to Be Used
in Azure Logic Apps
We need to create the JSON body which we’ll use to create the schema.
I used objgen.com/json to quickly create this piece, but you can just
manually type it if you want.
Here is the JSON payload with some sample data:
You’ll want to use the New Email Trigger and use the Email Parser by Zapier
and allow it to connect to your mailbox that you created earlier.
For the next step, you’ll want to use an Action that is a POST request that
uses Webhooks by Zapier. When you get to the point to where it asks you
for a URL, use requestb.in to see what your HTTP client is sending or to
inspect and debug webhook requests. Now you have a URL that you can
use for testing. Ensure your payload is set to JSON and now you can select
the data from your parsed email (filename, csv, kml, gpx). You can leave the
rest of the fields as they are. When you finish your screen should look
like the following:
Go ahead and save and run the test. After you switch over to your
requestb.in you should see the output that matches the parsed data from
the email.
Note that the URL isn’t generated until we provide the parameters.
Go ahead and press Edit. Remember the JSON Schema from the
last post? Well, now is the time to paste it in. I’ll also
include it below:
Note: You can use the “Use sample payload to generate schema” option,
but I prefer the additional meta data that JSON Schema can provide.
You’ll now have a GET URL that you can put in Zapier and replace
the requestb.in that we stubbed out earlier.
Head back over to Zapier Editor and modify your Zap by editing
the template and replacing the requestb.in URL with your live
Azure Logic Apps ones.
Upload Files from a URL with
Azure Logic Apps
Open our existing Azure Logic App and we’ll use OneDrive to
automatically upload the files to my personal OneDrive account.
Typically, you’ll add an Action or Condition to trigger once the
HTTP request is complete.
Now you can pull the fields that we captured and use them as
dynamic content. For example, the GPX file contains the full URL,
so we can just use that dynamic field. For the destination URL,
we’ll construct the location we want it to go in our OneDrive
account. Note that I’ve also setup 2 additional OneDrive actions
for the KML and CSV file.
Now you’d want to send an email to your Zapier mailbox to test all
the pieces to this app. Now you can switch over to your OneDrive
account. If everything goes well and worked successfully you will
see your new files in your OneDrive folder.
Now you should create a project, then a function app, and select
which template that you want to use. After you select a template,
you’ll need to provide a name and an authorization level.
I typically fix this by going into the Azure Portal and clicking
on my Azure Function. I then click on Platform Features and
Advanced tools(Kudu).
I then navigate to wwwroot and hit edit on the host.json file.
Inside the editor, add the routePrefix to define the route prefix.
So if I wanted the route prefix to be blank, then I’d use the
following:
Simply restart your Azure Function and now my URL is
accessible without api.
Keep in mind that best practice (as far as I can tell) is to use api, but wanted
to flag this as only you can make your design decisions.
Productivity
If you jumped straight to this section, then you certainly understand
the spirit of what I originally wanted to achieve with Azure Tips and
Tricks - simply to be more productive with Azure. In this set of tips,
I’ve gone back to the first tip that I ever wrote describing how you
can use keyboard shortcuts within the Azure Portal to navigate more
effectively. We’ll also cover how you can apply tags to your Azure
resources to logically organize them by categories. We’ll wrap up
with using Azure Cloud Shell, which provides an interactive, browser-
accessible shell for managing Azure resources, and how you can
quickly take advantage of it with Visual Studio Code in the browser
or on your local development machine.
Actions
CTRL+/ Search blade menu items
ALT+SHIFT+Up Move favorites up
ALT+SHIFT+Down Move favorites down
G+/ Search resources (global)
G+N Create a new resource
G+B Open the ‘More services’ pane
Navigation
G+, Move focus to command bar
G+. Toggle focus between top bar and side bar
Go to
G+D Go to dashboard
G+A Move favorites up
G+R Move favorites down
G+number Search resources (global)
If you pin the blade (by pressing the pin in step 4) you’ll see the
following on your Azure Portal dashboard:
Did you know that you can access Visual Studio Code within a
Cloud Shell instance?
And since this is based upon the open-source Monaco project that
powers Visual Studio Code, you can expect we'll see more features
added over time. As of the publication time of this eBook, it
automatically includes authorization for pre-installed open source
tools like Terraform, Ansible, and InSpec. So what are you waiting
for? Go check out now!
Conclusion
Thanks for reading and I hope that you enjoyed the top tips of
Azure Tips & Tricks since the creation of the series. While we’ve
discussed four broad sections that covered web, data, serverless
& productivity, there are 130+ additional tips waiting on you that
cover additional topics such as :
• App Services
• CLI
• Cloud Shell
• Cognitive Services
• Containers
• Cosmos DB
• Functions
• IoT
• Logic Apps
• Portal
• PowerShell
• Productivity
• Storage
• SQL and Search
Start free
signing off...
Azure Tips and Tricks
azuredev.tips
Copyright © 2018 by Microsoft Corporation. All rights reserved. No part of the contents of this book may be
reproduced or transmitted in any form or by any means without the written permission of the publisher.