SQL queries with PHP on MYSQL database – Azure

A few days ago i activated Azure for students through Dreamspark. I am very happy microsoft give those tools for free in students. After searching the options that are available for free, i found that i could use some mysql databases. As mysql is very common and frequently used, i created a database and wanted to add some data. Unfortunately i couldn’t find a tool for managing the database. As you may know most linux servers come with phpmyadmin pre-installed. So what about Azure?

There are many options for Azure.

  1. You can connect to your database with mysql commands using mysql command line tool.
  2. You can download a GUI tool and do the work (mysql workbench)
  3. You can use any php code to connect.

So here comes this github project with which you can connect on a mysql database that is stored in Azure.

See more details in the below pictures

First of all you must create a mysql database.

new_mysql

After you create the database you must press properties window to see the connection credentials. Those are: Host name, Database Name, Username, Password.

connection

Then you are ready to start using your mysql database. And here comes the PHPqAzure.

As you can see, after entering your credentials you can run your queries. Query result is returned after query is executed.

Example:

Create a test table.

 

create_table

Add some data

insert

And you are ready. You can see the result with a mysql GUI management tool like Mysql Workbench.

program_view

You can perform as many queries as you want. Make sure your queries executed successfully with the results tab.

If i enter something wrong then the result will inform me for that.

wrong-query

 

Application Insights VS2015 failed to add applicationinsights.config

If you ever deal with the problem

in Visual studio 2015 and Windows 10 you only have to create a file and name it  ApplicationInsights.config with the code below. That’s because vs and nuget cannot create this file in the root folder of your project.

You must enter your specific InstrumentationKey for the application that you have registered through Azure portal for Insights.

The trick is that you must select Build Action as Content and Copy always to output folder

vs2015insights

UnauthorizedAccessException C# File.IO Async

I had to upgrade one application and put some extra functionality. So i added an async function that handles a .txt file and edit some fields.

So i used this code

 

But i also had a function in MainPage that asynchronously was reading the same file

 

Both functions were async so we could not determine when each function was running and which will be executed first.

So when i tried to run the app i came across with UnauthorizedAccessException because both function maybe were trying to access the file the same time. So i have to make one function wait. You can achieve that by many ways. I used the below function.

 

 

But i want to execute this code only once. So i used localSettings

 

 

How to install Windows 10 Technical Preview on Microsoft Hyper V (Windows 8.1 pro)

Here are the steps that you need to follow in order to install Windows 10 tech preview on Microsoft Hyper-V.

First of all go and download the .iso from

http://windows.microsoft.com/en-us/windows/preview-download

  1. Run hyper-v and click New -> Virtual Machine start-step
  2. Press next step1
  3. Give a name for the new virtual machine 
  4. Click Generation 1step3
  5. Provide ram size (suggest: 2 GB and more)step4
  6. Choose Not Connected for now.We will change that laterstep5
  7. Give your hard disk a size. You can store your virtual hard disc anywhere you want.You can also select one that already exists.step6
  8. Choose the bootable iso that you have downloaded from the windows insider pagestep7
  9. Press finishstep8
  10. Go to virtual switch managerstart-step
  11. New virtual network switch -> External
  12. Choose your network adapter and give virtual switch a namestep11
  13. Then select Settings -> Network Adapter -> and choose that you created on the previous stepstep12
  14. You are ready to rock!windows10-screenshot