I have created custom module and uploaded it in Azure Automation module section. Now when I try to run the command to fetch the list of modules, it is not showing over there. I have used PowerShell command and REST API also but it is giving me value of Default modules only. Is there any way I can get the details of custom module?
I have tried below 2 ways-
Powershell - https://learn.microsoft.com/en-us/powershell/module/az.automation/get-azautomationmodule?view=azps-7.0.0
API
Please help.
Here is the one of workaround that i was able to fetch the custom module that i have added to Azure Automation using Powershell
Added Microsoft teams custom module to my Azure Automation .
Run the following cmd to get all the modules default and custom
Get-AzAutomationModule -AutomationAccountName "<name>" -ResourceGroupName "<name>"
To Fetch the list of custom modules run the below cmd
Get-AzAutomationModule -AutomationAccountName "<name>" -Name "MicrosoftTeams" -ResourceGroupName "<name>"
Also can able to see it from azure portal itself. Also make sure that you have added the custom module with some functionality .
Related
I am trying to shutdown the VM using Azure Automation Account System Managed identity option.
However I am ending up with below error.
As per the other articles it is mentioned to upgrade the module Update-ModulesInAutomationToLatestVersion but I could not update due to below error. I am not sure what is the issue in the script. Same script works with AzureRunAsConnection option without issues ( script ).I even checked with simple login with System Managed Identity it successfully login and fetches the resource group names.
I have tested the above shared script in my automation account. Below are
the couple of observations:
You need to use Connect-AzureRMAccount -Identity cmdlet instead of 'connect-AzAccount` to connect to your subscription because the rest of the script that you have written using Azure RM cmdlets.
If we use AzureRM cmdlets in your run book script the job is getting suspended stating that Azure RM is going to retired and suggesting us to use Az Module in your workflow.
You can refer to this documentation on how to migrate your PowerShell scripts automatically from AzureRM to AZ modules.
If you want to perform start/stop on your virtual Machines you can leverage the Azure Automation start/stop during the off hours feature.
According to the MICROSOFT DOCUMENTATION and looking at your script the Azure Rm module is not supported and it has been updated to the latest version of Az module.
For more information please refer the below links:-
MICROSOFT DOCUMENT|Using a system-assigned managed identity for an Azure Automation account & Troubleshoot runbook issue.
I am trying to use some commands from PowerShell workflow from runbooks in Azure automation account. One of the command is Get-AzureWebsiteJob which uses Azure.Service PowerShell module. This module is not present in the PowerShell module gallery of the automation account. I didn't find it in PowerShell Gallery as well.
Am I missing anything trivial here? Either I need a way to import that module in automation account or need to be able to download as a zip so that I can upload it.
Actually the cmdlet Get-AzureWebsiteJob is in Azure module.
In the Azure module page -> Package Details section, you can find the cmdlet Get-AzureWebsiteJob is included. Here is the screenshot:
To use it in runbook, you just need import that module in automation account, or you can directly deploy that module to azure automation from Azure module like below:
I'm attempting to enable accelerated networking in Azure from the Azure Powershell Az module. However, I get an error stating that 'No registered resource provider found for location "my location" and API version "2019-07-01"'
I've found that the latest API version available is 2019-06-01. I was able to get a list of API versions, but they are in date format and the Az Install-Module seems to only accept numbers such as 2.2.0.
((Get-AzResourceProvider -ProviderNamespace Microsoft.Network).ResourceTypes | Where-Object ResourceTypeName -eq networkInterfaces).ApiVersions
The code that generates the error:
$nic = Get-AzNetworkInterface -ResourceGroupName "myResourceGroupName" -Name "myNicName"
I'm looking for a way via Az powershell cmdlets or a web site reference to get the actual version number so I can install the correct version to interface with my Azure environment.
The answer here is to use Cloud Shell directly from the Azure portal. This is no longer a coding question so the community can feel free to do what they want with this.
Check for your Powershell and AzModule versions. The Current API version available is '2019-08-01':
Update your Powershell/AzModule and the command will work just fine. Refer to the documentation:
https://learn.microsoft.com/en-us/powershell/azure/install-az-ps?view=azps-2.7.0#requirements
I need to get property like "DiskState", I am using cmd-let Get-AzureRMdisk, and what I got:
1) from my laptop, using connect-azurermaccount then get-azurermdisk, doesnt give expected property 2) I tried from Automatio account, created a runbook and then paste my code there, the same, I got more values but didn't get "diskstate" value 3) I see that I can get it from Azure Cloud Shell console. I would like to get this value from a script running as a runbook. Moreover I tried to use command like --> Get-AzureRmDisk | Where-Object ManagedBy -ne $null, but didnt get any interesting results. Is there any matheto do get this mentioned property "diskstate" using powershell runbook from Automation account?
Why not, the PowerShell command Get-AzureRMDisk show you the DiskState as you want:
Additional, I recommend you use the Az module of the PowerShell while the AzureRM module is Migrated to it. See Migrate Azure PowerShell from AzureRM to Az.
Update:
But in the Runbook Get-AzureRMDisk does not show the property, you need to use the Get-AzDisk to achieve the purpose after you import the Az module and it shows like this:
I'm writing a PowerShell deployment script which automates the creation of my Azure resources and an accompanying ServicePrincipal.
Here is the code I'm using, which I've tested and works when run directly from PowerShell with the latest Azure 1.0.4 SDK module:
$ResourceGroupName = "my-resource-group"
$ADAppIdentifierUri = [string]::Concat("https://", $ResourceGroupName, ".azurewebsites.net")
# Generate a password for the AD application
$ServicePrincipalPassword = [Guid]::NewGuid().ToString().Replace("-", "")
# Create the Azure AD Application and service principal, and only assign access to our resource group
$AzureADApplication = New-AzureRmADApplication -DisplayName $ResourceGroupName -HomePage $ADAppIdentifierUri -IdentifierUris $ADAppIdentifierUri -Password $ServicePrincipalPassword
When I run this code using my ResourceGroup project deployment script in Visual Studio, I get the following error:
New-AzureRmADApplication : Unable to cast object of type 'Microsoft.Azure.TokenCloudCredentials' to type 'Microsoft.Azure.Common.Authentication.AccessTokenCredential'.
According to the stack trace the exception was raised at the start of the command New-AzureRmADApplication, so the exception is happening internally in the Azure SDK code unfortunately.
I've browsed the source code of the SDK in the following files and could not find any insight:
https://github.com/Azure/azure-powershell/blob/f803b991daa7eeeea1217238ab071c8d83de34be/src/ResourceManager/Resources/Commands.Resources/ActiveDirectory/NewAzureADApplicationCommand.cs
https://github.com/Azure/azure-powershell/blob/956d0ca795acfce67d8f142bf059ab2b8ab2c67b/src/ResourceManager/Resources/Commands.Resources/Models.ActiveDirectory/ActiveDirectoryClient.cs
https://www.symbolsource.org/Public/Metadata/NuGet/Project/Microsoft.Azure.Graph.RBAC/1.6.0-preview/Release/.NETFramework,Version%3Dv4.0/Microsoft.Azure.Graph.RBAC/Microsoft.Azure.Graph.RBAC/Generated/GraphRbacManagementClient.cs?ImageName=Microsoft.Azure.Graph.RBAC
I can only find one person who's encountered this same error at this link here:
https://azure.microsoft.com/en-us/documentation/articles/resource-group-authenticate-service-principal/
However, the solution there does not make sense to me because I am not using a management certificate to authenticate, and I don't have any management certificates listed on the manage.windowsazure.com site.
This is an issue (i.e. bug) when using token based authentication with the AzureRMAD* cmdlets. When you run the script from VS, VS uses the token you have from the VS sign-in to avoid prompting for auth. To work around it, you have to run it outside of VS using credentials.
There is an internal work item tracking this but if you want to monitor progress you can file an issue here: https://github.com/Azure/azure-powershell/issues/