Avkash Chauhan's Blog

Windows Azure, Windows 8, Cloud Computing, Big Data and Hadoop: All together at one place.. One problem, One solution at One time...

How to add Certificate in your Azure VM using Startup task

How to add Certificate in your Azure VM using Startup task

Rate This
  • Comments 1

Here are the detailed steps:

1. Create a folder name Startup in your Project

2. Add your certificate in this folder (In this case I have added MyCert.cer)

3. Create a command batch file name addcert.cmd in the same folder and as following command:

 

 

 certutil -addstore root Startup\MyCert.cer

If you want to delete a certificate in the startup task use the command as below:

certutil -delstore  My <certificate_name>

Note: Certificate_Name can be take from CN entry. 

At this point your VS2010 project will look like as below:

 

4. Now add the following code in your Service Definition (ServiceDefinition.csdef):

 

<Startup> <Task commandLine="Startup\AddCert.cmd" executionContext="elevated" taskType="simple"> </Task> </Startup>

That’s it!! Now you can verify the selected certificate is included in the certificate root store by RDP to your Azure VM.

Leave a Comment
  • Please add 4 and 1 and type the answer here:
  • Post
  • hi,

    i did as mentioned above but i am getting an error while adding the startup tast

    "Role instances are taking longer than expected to start" but when i comment the task section in my csdef file it works fine. is anything more need to be done and also can you please post how to add .pfx certificate having password in azure VM.

Page 1 of 1 (1 items)