Compartilhar via


How to add Certificate in your Azure VM using Startup task

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.

Comments

  • Anonymous
    July 10, 2011
    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.