Skip to main content

58 posts tagged with "azure"

View All Tags

· 6 min read

The first ever Github Universe viewing party in SriLanka took place on last Thursday organized by the Github Campus Experts in the country. It was an event to share all the exciting news and updates on Github and it was a great success. I decided to write this blog based on the session i presented on “Github Actions”. It’s amazing to see the new features announced by the Github over the span of last 12 months out of which Github actions was the latest one and it was made generally available on  few days ago (November 13, 2019) to build CI/CD pipelines from GitHub itself. I was excited about this announcement and tested it with two of my projects and I have to say I’m impressed.

As a example, in this post I will explain about how to build a “Emotion detection app” with angular and deploy it on one of the public cloud(Azure) with Github Actions. Below is the simple architecture diagram to get an understanding on how I am going to leverage Github action to deploy my Angular application to the Cloud. Here is the simple architecture of the application that i have demonstrated.

PreRequisities:

Step 1 : Create the Resource group On Azure :

As the first step, we need to create the AppService on Azure to Deploy the Angular application.Navigate to https://portal.azure.com/ and you will be directed to the home page on the portal. Let’s create a resource group to group the resources we create.

Step 2: Create the App service to deploy the Angular app.

As the second step, create an app service to deploy the Angular application

Step 3: Create the Cognitive Service

Create Cognitive service to integrate the emotion detection part. We will use detect api to detect the attributes in a picture.

If you want to store the data , you can create a new cosmosdb to store the results which i have not included here.

Step 4: Code the Angular App

You need to create the component to upload a file and pass the file to the cognitive service to detect the attributes and use ngFor on the template to display the results.

Get the keys of the cognitive service and the url from the portal as follow

You can access the whole code from here. Make sure to replace the Ocp-Apim-Subscription-Key and the url according to the endpoint you created above.

makeRequest() {
let data, contentType;
if (typeof this.image === 'string' && !this.image.startsWith('data')) {
data = { url: this.image };
contentType = 'application/json';
} else {
data = this.fileToUpload;
contentType = 'application/octet-stream';
}

const httpOptions = {
headers: new HttpHeaders({
'Content-Type': contentType,
'Ocp-Apim-Subscription-Key': 'eb491c17bd874d2f9d410eedde346366'
})
};

this.http
.post(
'https://eastus.api.cognitive.microsoft.com/face/v1.0/detect?returnFaceId=true&returnFaceLandmarks=false&returnFaceAttributes=emotion',
data,
httpOptions
)
.subscribe(body => {
if (body && body[0]) {
console.log(body);
this.output = body;
this.thing = body[0].faceAttributes.emotion;
this.result = this.getTop();
this.noFace = false;
} else {
this.noFace = true;
}
});
}

Step 5: Push the Code to Github

You can push the code to your own repository on GitHub and let’s create the build and deploy pipeline via the GitHub actions. Navigate to your repository and click on Actions

Step 6: Create Github Action with Workflow

Create a new workflow by clicking on the new workflow. You will get to see different templates by default to build the pipeline according to the application language as below

In this case, I will create my own workflow by clicking on the setup workflow for yourself. Name the workflow as angular.yaml. You can see a new file being generated under your repository as github_action_angular/.github/workflows/azure.yml

name: Deploy to Azure
on:
push:
branches:
- master
env:
AZURE_WEBAPP_NAME: github-actions-spa
AZURE_WEBAPP_PACKAGE_PATH: './dist/angulargithubaction'
NODE_VERSION: '10.x'

jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master
- name: Use Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v1
with:
node-version: ${{ env.NODE_VERSION }}
- name: Install dependencies
run: npm install
- name: Build
run: npm run build -- --prod
- name: 'Deploy to Azure WebApp'
uses: azure/webapps-deploy@v1
with:
app-name: ${{ env.AZURE_WEBAPP_NAME }}
publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}

The workflow is really simple. As you see it includes a name and few actions starting with when you need to do the build and deploy. Buildon: push indicates that whenever there is a new commit the code needs to be built again. Also you have to define NodeJS version and will run our build on ubuntu server. And you have a few regular steps that we usually do with building angular application if we are familiar with Angular apps development.

Also as an option you  run that configuration only for branches other than master. For master branch we have separate configuration (with deployment to Azure). So it is flexible to maintain different workflows to different branches/environments. Is not that cool?

Step 7: Configure the Pipeline,Secrets

As the next step you need to create in GitHub Secrets page new secrets. It’s important to save the secret name whenever you need to deploy to production/development using secrets is one of the best practice. You can get the the keys from the publish profile of the app service.

Create new secret as above with the values got from profile.

  We have to configure the values in angular.yaml as follows:

  • app-name — application name in Azure
  • publish-profie — name of the secret from GitHub
  • package — path to directory which we would like to deploy (in above example: ./dist/yourSPAApp.

And that’s it. Really clear and simple! You can just check if the deployment has been successful or not by navigating to the Kudu.

And you can see the application working successfully on Azure. As the next step you can include unit tests to run when you do the build. Using the Angular CLI and Github Actions, it has become very easy to create and test frontend Web apps. Check out the fulling working demo repo below as well as the current build status for the demo!.

Start using Github Action and deploy your app within few seconds. You can use Github actions to deploy any application to any cloud as i've explained above.

You can access the Session Slides from here and the repository from here.

· One min read

One of the interesting queries that i got from my colleague is that how to get rid of the metadata properties when retrieving documents from Cosmosdb. It seemed like a very reasonable expectation to have the option with the document "GET" API call to be able to retrieve exactly what he created using the document "POST" API call, without these Cosmosdb Metadata properties mixed in:

"_rid":"ehszALxRRgACAAAAAAAAAA==", "_ts":1408340640, "_self":"dbs\/ehszAA==\/colls\/ehszALxRRgAALxRRgACAAAAAAAAAA==\/", "_etag":"00002500-0000-0000-0000-53f192a00000", "_attachments":"attachments\/"

As of now there is no direct way to omit these properties when you are querying the documents. However, cosmosdb team is aware of this feature request, understand the reasons for it, and are considering it for a future release.

For those who are wondering how to omit these system generated properties, you can simply handle this with a User Defined Function.

function stripMeta(doc) {
var metaProps = ["_rid", "_ts", "_self", "_etag", "_attachments"];
var newDoc = {};
for(var prop in doc) {
if (metaProps.indexOf(prop) == -1) {
newDoc[prop] = doc[prop];
}
}

return newDoc;
}

And you can retrieve your documents with whatever queries as follows,

select value udf.stripMeta(c) from c

Hope this helps someone out there.

· 5 min read

One of the frequent questions i get from partners is on how to set Timezone for an application running on Azure app service. It is too easy to change the timezone for an app service hosted in windows OS , but the same settings do not apply for an app service hosted in Linux or Web App running using a container.

How to configure for App Service on Windows:

If your app service plan runs on Windows, As a quick fix, in the configuration, just add a setting named “WEBSITE_TIME_ZONE” with the value you want:

Timezone configuration on Web App

How to configure for AppService on Linux:

If your App Service Plan is Linux, you need to do it differently. You need to set TZ variable in Application settings.

Say if you want to set your timezone to Asia/Kolkata. you need to set the TZ variable value as

Timezone configuration on Linux Web App

Timezone Values:

The supported timezone values are listed here.

Value="Morocco Standard Time" For (GMT) Casablanca
Value="GMT Standard Time" For (GMT) Greenwich Mean Time : Dublin, Edinburgh, Lisbon, London
Value="Greenwich Standard Time" For (GMT) Monrovia, Reykjavik
Value="W. Europe Standard Time" For (GMT+01:00) Amsterdam, Berlin, Bern, Rome, Stockholm, Vienna
Value="Central Europe Standard Time" For (GMT+01:00) Belgrade, Bratislava, Budapest, Ljubljana, Prague
Value="Romance Standard Time" For (GMT+01:00) Brussels, Copenhagen, Madrid, Paris
Value="Central European Standard Time" For (GMT+01:00) Sarajevo, Skopje, Warsaw, Zagreb
Value="W. Central Africa Standard Time" For (GMT+01:00) West Central Africa
Value="Jordan Standard Time" For (GMT+02:00) Amman
Value="GTB Standard Time" For (GMT+02:00) Athens, Bucharest, Istanbul
Value="Middle East Standard Time" For (GMT+02:00) Beirut
Value="Egypt Standard Time" For (GMT+02:00) Cairo
Value="South Africa Standard Time" For (GMT+02:00) Harare, Pretoria
Value="FLE Standard Time" For (GMT+02:00) Helsinki, Kyiv, Riga, Sofia, Tallinn, Vilnius
Value="Israel Standard Time" For (GMT+02:00) Jerusalem
Value="E. Europe Standard Time" For (GMT+02:00) Minsk
Value="Namibia Standard Time" For (GMT+02:00) Windhoek
Value="Arabic Standard Time" For (GMT+03:00) Baghdad
Value="Arab Standard Time" For (GMT+03:00) Kuwait, Riyadh
Value="Russian Standard Time" For (GMT+03:00) Moscow, St. Petersburg, Volgograd
Value="E. Africa Standard Time" For (GMT+03:00) Nairobi
Value="Georgian Standard Time" For (GMT+03:00) Tbilisi
Value="Iran Standard Time" For (GMT+03:30) Tehran
Value="Arabian Standard Time" For (GMT+04:00) Abu Dhabi, Muscat
Value="Azerbaijan Standard Time" For (GMT+04:00) Baku
Value="Mauritius Standard Time" For (GMT+04:00) Port Louis
Value="Caucasus Standard Time" For (GMT+04:00) Yerevan
Value="Afghanistan Standard Time" For (GMT+04:30) Kabul
Value="Ekaterinburg Standard Time" For (GMT+05:00) Ekaterinburg
Value="Pakistan Standard Time" For (GMT+05:00) Islamabad, Karachi
Value="West Asia Standard Time" For (GMT+05:00) Tashkent
Value="India Standard Time" For (GMT+05:30) Chennai, Kolkata, Mumbai, New Delhi
Value="Sri Lanka Standard Time" For (GMT+05:30) Sri Jayawardenepura
Value="Nepal Standard Time" For (GMT+05:45) Kathmandu
Value="N. Central Asia Standard Time" For (GMT+06:00) Almaty, Novosibirsk
Value="Central Asia Standard Time" For (GMT+06:00) Astana, Dhaka
Value="Myanmar Standard Time" For (GMT+06:30) Yangon (Rangoon)
Value="SE Asia Standard Time" For (GMT+07:00) Bangkok, Hanoi, Jakarta
Value="North Asia Standard Time" For (GMT+07:00) Krasnoyarsk
Value="China Standard Time" For (GMT+08:00) Beijing, Chongqing, Hong Kong, Urumqi
Value="North Asia East Standard Time" For (GMT+08:00) Irkutsk, Ulaan Bataar
Value="Singapore Standard Time" For (GMT+08:00) Kuala Lumpur, Singapore
Value="W. Australia Standard Time" For (GMT+08:00) Perth
Value="Taipei Standard Time" For (GMT+08:00) Taipei
Value="Tokyo Standard Time" For (GMT+09:00) Osaka, Sapporo, Tokyo
Value="Korea Standard Time" For (GMT+09:00) Seoul
Value="Yakutsk Standard Time" For (GMT+09:00) Yakutsk
Value="Cen. Australia Standard Time" For (GMT+09:30) Adelaide
Value="AUS Central Standard Time" For (GMT+09:30) Darwin
Value="E. Australia Standard Time" For (GMT+10:00) Brisbane
Value="AUS Eastern Standard Time" For (GMT+10:00) Canberra, Melbourne, Sydney
Value="West Pacific Standard Time" For (GMT+10:00) Guam, Port Moresby
Value="Tasmania Standard Time" For (GMT+10:00) Hobart
Value="Vladivostok Standard Time" For (GMT+10:00) Vladivostok
Value="Central Pacific Standard Time" For (GMT+11:00) Magadan, Solomon Is., New Caledonia
Value="New Zealand Standard Time" For (GMT+12:00) Auckland, Wellington
Value="Fiji Standard Time" For (GMT+12:00) Fiji, Kamchatka, Marshall Is.
Value="Tonga Standard Time" For (GMT+13:00) Nuku'alofa
Value="Azores Standard Time" For (GMT-01:00) Azores
Value="Cape Verde Standard Time" For (GMT-01:00) Cape Verde Is.
Value="Mid-Atlantic Standard Time" For (GMT-02:00) Mid-Atlantic
Value="E. South America Standard Time" For (GMT-03:00) Brasilia
Value="Argentina Standard Time" For (GMT-03:00) Buenos Aires
Value="SA Eastern Standard Time" For (GMT-03:00) Georgetown
Value="Greenland Standard Time" For (GMT-03:00) Greenland
Value="Montevideo Standard Time" For (GMT-03:00) Montevideo
Value="Newfoundland Standard Time" For (GMT-03:30) Newfoundland
Value="Atlantic Standard Time" For (GMT-04:00) Atlantic Time (Canada)
Value="SA Western Standard Time" For (GMT-04:00) La Paz
Value="Central Brazilian Standard Time" For (GMT-04:00) Manaus
Value="Pacific SA Standard Time" For (GMT-04:00) Santiago
Value="Venezuela Standard Time" For (GMT-04:30) Caracas
Value="SA Pacific Standard Time" For (GMT-05:00) Bogota, Lima, Quito, Rio Branco
Value="Eastern Standard Time" For (GMT-05:00) Eastern Time (US & Canada)
Value="US Eastern Standard Time" For (GMT-05:00) Indiana (East)
Value="Central America Standard Time" For (GMT-06:00) Central America
Value="Central Standard Time" For (GMT-06:00) Central Time (US & Canada)
Value="Central Standard Time (Mexico)" For (GMT-06:00) Guadalajara, Mexico City,Monterrey
Value="Canada Central Standard Time" For (GMT-06:00) Saskatchewan
Value="US Mountain Standard Time" For (GMT-07:00) Arizona
Value="Mountain Standard Time (Mexico)" For (GMT-07:00) Chihuahua, La Paz, Mazatlan
Value="Mountain Standard Time" For (GMT-07:00) Mountain Time (US & Canada)
Value="Pacific Standard Time" For (GMT-08:00) Pacific Time (US & Canada)
Value="Pacific Standard Time (Mexico)" For (GMT-08:00) Tijuana, Baja California
Value="Alaskan Standard Time" For (GMT-09:00) Alaska
Value="Hawaiian Standard Time" For (GMT-10:00) Hawaii
Value="Samoa Standard Time" For (GMT-11:00) Midway Island, Samoa
Value="Dateline Standard Time" For (GMT-12:00) International Date Line West

To verify that whether offset is updated or not navigate to Console and execute time command

Also, note that TZ codes are different from the Windows codes. Here's the reference database:

https://en.wikipedia.org/wiki/List_of_tz_database_time_zones

I hope it helps someone out there.

· 2 min read

There are few mandatory sites that every developer on azure should know. This post will contain a curated list of awesome websites which will definitely help.

Azure Checklist - This checklist is your guide to the best practices for deploying secure, scalable, and highly available infrastructure in Azure

Devops Generator - It is really a nice tool to get you a starting point for your demos on azure devops

Azure Charts - Azure heatmap where you can see the changes to Microsoft cloud services in a heat map visualisation

Cosmic notes - Learn more about Azure Cosmos DB database, one Cosmic Note at a time!

AKS Workshop - You’ll go through tasks that will help you master the basic and more advanced topics required to deploy a multi-container application to Kubernetes on Azure

Price Calulator - Pricing calculator to help you understand the pricing. This tool will make it easier to understand the pricing of the different services/products.

Azure VM pricing - Find and compare Azure Virtual machines specs and pricing on a one page.

Azure IoT Developer Kit - The Microsoft Azure MXChip IoT Developer Kit (a.k.a DevKit) can be used to develop and prototype IoT solutions leveraging Microsoft Azure services. It includes an Arduino compatible board with rich peripherals and sensors, an open-source board package and a growing projects catalog.

Severless Library - Collection of azure functions xamples. If you are looking for some ideas on how Azure functions can be leveraged or need an example for your scenario this is a great resource.

Azure speed test - Use this tool to measure the latency from your web browser to the Blob Storage Service in each of the Microsoft Azure Data Centers.

App Migration - Assess any app with an endpoint scan. Download the Migration Assistant and start your .NET and PHP app migration to Azure App Service.

The above tools/sites have helped me a lot in the journey of myself as a Azure developer. I'm sure this would help any of the developer who wants to get started on Azure.

· One min read

There are few cool speed test tools available out there which allows you to test network latencies and speed to data centers from different countries and locations.  Along with finding the closest Datacenter near your location, it tests the storage latency as well as upload and download speeds. 

Check it out from the following urls:

𝗔𝘇𝘂𝗿𝗲: http://azurespeedtest.azurewebsites.net

𝗔𝗪𝗦: https://cloudharmony.com/speedtest-for-aws

Make use of the above tools to identify which region is suitable for your solution. Hope it helps.