Create Azure Virtual machine

Abhishek Rao 1 Reputation point
2020-08-04T12:06:08.967+00:00

Hi,

I tried with two ways to create VM in azure by following methods

  1. Using Az azure powershell module
  2. Using ARM template.

I was able to create VM in azure manually. But I am not able to do with Azure pipeline.
So my questions are

  1. Which pipeline task I have to use to run my powershell script.( i.e plain Powershell Task or Azure powerShell Task)
  2. If we can use Azure power shell task, which version we have to use.

I have added the Screenshots of the error i was getting.
please suggest solution for the above mentioned issues.

Thanks,
Abhishek15495-errorno1.png15436-errorno2.png15437-errorno3.png

Community Center | Not monitored
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. SwathiDhanwada-MSFT 19,073 Reputation points Moderator
    2020-08-05T10:44:21.637+00:00

    @Abhishek Rao To deploy any resources at management group scope, subscription scope or resource group scope, you can take advantage of the "ARM Template deployment" task which is available for Azure Pipelines. In my opinion, this is way easier then using Azure PowerShell Task.

    15783-2020-08-05-14-01-37-ppe-pipelines-and-7-more-pages.png

    From the snapshots provided, these can be some of the reasons for the errors you are prompted with.

    1)Kindly note managed identities are not supported on Microsoft Hosted Agents. You will have to set-up a self hosted agent on an Azure VM and configure managed identity for the virtual machine.

    2) If you are using Microsoft Hosted Agents, I would suggest you to create Service connection with Azure Resource Manager using service principle. For more information on service principal, refer this document.

    3) If you are using self hosted agents, kindly install all the required Az PowerShell modules on self-hosted agent.

    4) Here is a document which lists on troubleshooting Azure Resource Manager service connections which can help you fix the connection issue.

    Answering to your questions :

    1) Which pipeline task I have to use to run my powershell script.( i.e plain Powershell Task or Azure powerShell Task) - Use Azure PowerShell Task

    15809-2020-08-05-16-12-58-test-pipelines-and-8-more-page.png

    2) If we can use Azure power shell task, which version we have to use. - In my opinion , always use latest version


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.