Get azure account information inside virtual machine - azure

I have got a question. Suppose I have a virtual machine running inside my windows azure account.
Now I need to write some c# program(or whatever the language will be) that can give me my account name and virtual machine name on which it is running. Is it possible? If yes then pls tell me how.
Thanks in advance

I believe the only information about Azure environment you can get hold of is whatever Azure REST Management API can provide which implies you have to authenticate first. However, to get the virtual machine name from within the C# app, it's sufficient to use regular .NET fx calls, such as System.Environment.MachineName

Related

Azure SDK: How do I get the public IP address of the current machine my software is running on at runtime?

I'm trying to figure out how to capture the following IP address at run-time using the Azure SDK:
How do I get this information via the Azure SDK from within the software that is actually running on this VM. The AWS SDK has a trivially easy static method for looking this up.
Maybe the Get Deployment operation will give you what you need?
This really should be easier in Azure though...

Create virtual machines with Windows Azure php sdk

I am trying to figuring out how to create virtual machines with windows azure php sdk https://github.com/Azure/azure-sdk-for-php , I can't seem to understand on how to do this as there is any mention about virtual machines in the sdk.
Any help will be very apreciated.
Thanks
The Azure-SDK-for-PHP offers Service Management (see https://github.com/Azure/azure-sdk-for-php/blob/master/README.md) to spin up app services or VM’s. I’m not sure if it already includes support for managing Docker containers, but since it’s all REST API in the background, it should not take too much time to write a few lines to have it do the same thing. But for VM’s you can definitely manage them through the SDK.
If you need code samples, ping me. I’d love to share my knowledge.
I think azure-php-sdk is for using azure storage etc. it's not for creating VM.
Normally to create VM throught management portal and Windows azure powershell.

How can an Azure website determine which region it is running in?

I will be placing an Azure website, in several regions. Then configuring the Azure Traffic Manager to distribute requests to each region.
The website needs to know which region it is running in. Is there an API available to determine this? Or, is my only choice, to define a REGION app setting, that is set appropriately for each Azure website?
I had the same question today, and found this thread. It seems that Web Apps now do include the promised environment variable showing the region in which they are deployed.
I simply used:
string region = Environment.GetEnvironmentVariable("REGION_NAME");
and it worked fine (note that it returns null when run outside Azure e.g. in Visual Studio).
I got a response, to my question, on the Microsoft Azure DNS and Traffic Manager forum.
The answer was:
There's no handy way currently. In the Azure Powershell, you could use Get-AzureWebsite to read the WebSpace value, which is structured as Region+"webspace".
For now it's easier to just add it to the app setting, like you suggested. We'll have the region value as an environment variable in a later release.
So, as suggested, we will just use an app setting to tell the website what region it is running in. We will switch over, to the environment variable, when it becomes available.

Register COM/dll on Azure

i have one online portal which is having online payment facility , somehow my azure lost all settings and my payment gateway not working. i have used one dll for payment gateway so i think i need to register that on Azure please help me what should be done ?
Azure uses VMs with more or less usual Windows Server installations. You can register a COM dll there no problem from under any process having sufficient privileges.
That's such a usual procedure that I don't even know what to add - perhaps you should provide more details on where you've got stuck.

Windows Services in Windows azure

Does windows Azure supports windows Services ?, ...
I develop an application that has among its components a windows service that every hour sends an email with information.
Is this supported in Windows Azure?,
Thanks!!
You might find the worker role is a better fit for running a process every hour. If you have the code for the WIndows Service it should not be hard to impleemnt it in a worker role.
You will, however, have to use a 3rd party service to send the email, as this is not supported in Azure.
Regards,
Alan
Yes, you can do this*. In order to install a Windows Service in a PaaS worker role (or web role), you will need to create a startup script that installs the service on boot (and checks to see if already installed on subsequent boots).
If you are using IaaS VMs, then the installation is straightforward - just do as you do today.
*Windows Azure Websites is a shared model, so installing services is not supported there.
To combine both Alan Smith's and dunnry's answers, both are correct -
You can install a windows services on a PaaS role using a startup script (other than web sites).
If you're using a Virtual Machine you just install the service on the VM
But Alan is completely correct that the best route forward in most cases is migrating the code to a worker role which is usually quite straight forward, would work best and would be easier to maintain.
Having said all of that - sending emails from within Azure is not necessarily a good idea as many mail servers black list the ips (turns out Azure is a great platform for spammers)
I want to make an extra addition to Alan and Yossi's answers. It's important to know the why, because simply installing the Windows Service shouldn't be a problem.
But if you do this you'll be missing out on something very important. If you run all of your code in the actual Worker Role process you'll get the monitoring for free. This means, if your process crashes for whatever reason, Windows Azure will restart the instance to make sure the process gets back online.
Now if you simply go and install a Windows Service through a startup script you won't be able to take advantage from this automated monitoring. You'll need to make sure you have some kind of recovery (this could be a setting on the Windows Service or a different process). But it's simply too much work for something you could get for free.
I would suggest using a Extra-Small VM using a windows template that is already offered. It's the same cost as the worker role and will let you provision your service without any issues. You would install your service the same as you would on any on premises server.
If you don't need to have the same sort of failover scenario that your web roles do then this s a good option.

Resources