How to schedule automatic Azure VM creation with Image Gallery

Lewis Lee 40 Reputation points
2024-09-05T09:27:13.54+00:00

How to schedule automatic Azure VM creation with Image Gallery

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
9,013 questions
Azure Automation
Azure Automation
An Azure service that is used to automate, configure, and install updates across hybrid environments.
1,366 questions
{count} votes

Accepted answer
  1. Anusree Nashetty 4,375 Reputation points Microsoft External Staff Moderator
    2024-09-09T09:36:57.0933333+00:00

    Hi Lewis Lee,

    I'm glad that you were able to resolve your issue and thank you for posting your solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "The question author cannot accept their own answer. They can only accept answers by others ", I'll repost your solution in case you'd like to "Accept " the answer.

    Issue:

    How to schedule automatic Azure VM creation with Image Gallery.

    Solution:

    It is resolved by using Managed ID with the following code

    try
    {
        "Logging in to Azure..."
        Connect-AzAccount -Identity
    }
    catch {
        Write-Error -Message $_.Exception
        throw $_.Exception
    }
    

    Details refer to this:

    https://learn.microsoft.com/en-us/azure/automation/migrate-run-as-accounts-managed-identity?tabs=sa-managed-identity

    If you have any other questions or are still running into more issues, please let me know. Thank you again for your time and patience throughout this issue.

    Please remember to "Accept Answer" if any answer/reply helped, so that others in the community facing similar issues can easily find the solution.

    Thank you.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Lewis Lee 40 Reputation points
    2024-09-09T01:46:16.3366667+00:00

    Thanks for your reply and I eventually resolved this by using Managed ID with the following code:

    try
    {
        "Logging in to Azure..."
        Connect-AzAccount -Identity
    }
    catch {
        Write-Error -Message $_.Exception
        throw $_.Exception
    }
    

    Details refer to this:

    https://learn.microsoft.com/en-us/azure/automation/migrate-run-as-accounts-managed-identity?tabs=sa-managed-identity

    0 comments No comments

Your answer

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