Possible bug with New-AzureDeployment - azure

The New-AzureDeployment cmdlet is not updating the Deployment Name with the value from the -Name parameter. As per MSFT's documentation here, the -Name parameter maps to the Deployment Name but when I tested, it was the Deployment Unique name that got updated with the value of -Name parameter. Moreover, I could use special characters like '.' and '/' in deployment name when uploading the package directly from portal, but the cmdlet wouldn't let me use any special characters
Wondering if someone had run into this issue?
Here is the screenshot of the error that I am seeing when using special characters
New-AzureDeployment : HTTP Status Code: BadRequest - HTTP Error
Message: The deployment name is invalid

Use the -Label option to specify user friendly name (your custom desired name that will be shown in the portal).
-Name option is for system-use, and is assigned to a GUID if not specified.
Here is where in the portal these switches are represented:

Related

Error result using New-AzApplicationInsightsContinuousExport - Can not perform requested operation on nested resource. Parent resource

I am trying to use the New-AzApplicationInsightsContinuousExport in the powershell since the Continuous Export feature is currently not available unless we migrate the current resource for application insight in workspace-based application resource. Unfortunately we do not have the authority to do it for now so thats why we are using the alternative method through powershell. I followed the instructions and created the sample storage creation found in the document of microsoft. Then after that used the sample command "New-AzApplicationInsightsContinuousExport". Did change the value based on the settings we have and execute it. But I encountered an error which is "Can not perform requested operation on nested resource. Parent resource". Been trying to find how to solve but unfortunately, I am stuck. Would someone help or direct me what should I do on this? Thanks! I posted the image of the command i executed.
enter image description here
enter image description here
I tried different approach of values that on the parameters that I think might work but its not working also. I also checked the "appinsighttest1" storage account configuration that was created by checking the settings, network, keys and other that might enable/visible for the command to work. My idea is the reason that it is not found maybe i have to enable something the storage account configuration. But right now i cant get it to work.
Error result using New-AzApplicationInsightsContinuousExport - Can not perform requested operation on nested resource. Parent resource:
"Parent resource 'test' not found: It means that no application insight resource with the name "test" has been created in Azure. You must first create an application insight in Azure Portal before using New-AzApplicationInsightContinuousexport.
I created in my environment as shown:
Using MSDoc as a reference, I tried in my environment with few modifications and successfully enabled continuous export with the respective command.
Script to run:
$context = $context = New-AzStorageContext -StorageAccountName "xxxstorageaccountname" -StorageAccountKey "xxxStorageaccountkey=="
$sastn = New-AzStorageContainerSASToken -Name <container> -Context $context -ExpiryTime (Get-Date).AddYears(50) -Permission w
$SASuri = "https://<storageaccount>.blob.core.windows.net/<containername>" + $sastn
New-AzApplicationInsightsContinuousExport -ResourceGroupName "<ResourceGroupName>" -Name "<applicationinsightname>" -DocumentType "Request","Trace", "Custom Event" -StorageAccountId "/subscriptions/<subscriptionID>/resourcegroups/<ResourceGroupName>/providers/Microsoft.Storage/storageAccounts/<storageaccount>" -StorageLocation EastUS -StorageSASUri $SASuri -DestinationType Blob
Output:
Note: This error might occur when you do not have enough right (access) to give/modify the permissions or roles. Assign "Storage Blob Data Owner" role for the storage account.

Set-AzureRmDiagnosticSetting : A parameter cannot be found that matches parameter name 'Name'

Set-AzureRmDiagnosticSetting : A parameter cannot be found that matches parameter name 'Name'.
After executing below command in Azure powershell task
Set-AzureRmDiagnosticSetting -ResourceId $resourceId -Name $diagnosticsettingname -Enabled $true -Categories $logarray -MetricCategory $metricsarray -WorkspaceId $work
I am getting exception as
"Set-AzureRmDiagnosticSetting : A parameter cannot be found that matches parameter name 'Name'."
As per the specification there is the -Name parameter in it. So why I am getting this error
As mentioned in the comment, I think your version of AzureRM.Insights module is old, please update the module with:
Update-Module -Name AzureRM.Insights -Force
And you should note, the AzureRm module has been deprecated, it will not be updated anymore, so I recommend you to use the new Az module instead of AzureRm, see this link to migrate to Az, then use the command Set-AzDiagnosticSetting.
Adding to this, if you want to do both Azure Diagnostics and leveraging an Azure Pipeline to do it, while programmatically doing this at scale with Azure Policy, you can check out this solution which should make this a bit easier to consume.
https://aka.ms/azpolicyPipeline
Without pipeline but automating the policies / policy initiative you can take a look at this project here: https://aka.ms/AzPolicyScripts
I found this post looking for something else related to a bug in Az cmdlets so figured I'd post since I had this detail handy.

How to Get-AzPublicIpAddress based on ResourceId?

Deployment script needs to enumerate existing public IP addresses from public IP prefix. Public IP Prefix object contains an array of resource identifies of individual public IP address.
I'd like to retrieve individual public ip addresses using provided resource identifier. Something like this:
Get-AzPublicIpAddress -ResourceId $resourceId;
Unfortunately, such signature doesn't exist. Get-AzPublicIpAddress expects ip address name as input parameter.
I understand that I can do:
Call Get-AzResource and get needed information from returned object [it means extra network call]
Parse needed information out of resource identifier [would like to avoid implementing this logic in PowerShell]
Question - are these the only options? Or maybe Az provides a built-in way of parsing resource identifiers?
You can use Get-AzResource -resourceId xxx -ExpandProperties | fl * for such requests. its a generic cmdlet that will work for any resource.
How is calling Get-AzResource an extra network call, compared to Get-AzPublicIpAddress? Its 1 call vs 1 call.
No, Az doesnt provide any parsing capabilities, they are not needed. You have tools to use resource id as well as individual names.
getting resource name out of resource id is fairly easy:
$resourceId -split '/' | Select-Object -Last 1
I don't think you can pass the -ResourceId directly to the command, all the built-in parameters are here : https://learn.microsoft.com/en-us/powershell/module/az.network/get-azpublicipaddress?view=azps-1.4.0. The most close way I can find is your option 2.
Not sure why you want to use Get-AzPublicIpAddress via ResourceId, even if we use -Name and -ResourceGroupName i.e. Get-AzPublicIpAddress -Name <publicIpName> -ResourceGroupName <ResourceGroupName>, it essentially also passes them into the request url of the rest api which the command called.
GET https://management.azure.com/subscriptions/xxxxxxxxx/resourceGroups/joywebapp/providers/Microsoft.Network/publicIPAddresses/joyVM-ip?api-version=2018-10-01
Actually, you could find /subscriptions/xxxxxxxxx/resourceGroups/joywebapp/providers/Microsoft.Network/publicIPAddresses/joyVM-ip is the ResourceId.
So I think it should be not too difficult for Microsoft to add the -ResourceId as a bulit-in parameter of the Get-AzPublicIpAddress command, if you want to improve it, you could give the feedback here.
Update:
Microsoft has replied to the this issue, see : https://github.com/Azure/azure-powershell/issues/8704#issuecomment-470604852
thanks for opening this feature request -- to provide more insight as to why the issues you mentioned above were closed: all new cmdlets that we ship in Az must conform to the pattern of having parameter sets that allow the user to do the following:
Provide the components of a resource (e.g., resource group name, resource name, etc.)
Provide the resource id of a resource
Provide the object representation of the resource (some cmdlets won't use this, like Get-*)
Later this year, we will begin generating our cmdlets using AutoRest (see this blog post for more details), and the above patterns will be enforced in the generator. Our goal then is to generate cmdlets for existing Azure services and replace our existing cmdlets with the generated ones.

How to check if Traffic Manager exists globally

I want to check whether a traffic manager is unique or not.
I am using Powershell Commandlets to get the information.
$profile = Get-AzureRmTrafficManagerProfile -Name $ResourceName -ResourceGroupName $ResourceGroupName
This command only checks for the traffic manager profile in the specified group. But traffic manager's are deployed globally. So, when I try to deploy with same traffic manager name in different resource group then error is thrown.
To avoid this error, I want to check at first only if that traffic manager exists globally. Didn't find any solution in documentation.
Is there any way to achieve this?
You can use the Test-AzureTrafficManagerDomainName powershell cmdlet.
C:\> get-help Test-AzureTrafficManagerDomainName
NAME
Test-AzureTrafficManagerDomainName
SYNOPSIS
Checks whether a domain name is available as a Traffic Manager profile.
SYNTAX
Test-AzureTrafficManagerDomainName [-DomainName] <String> [<CommonParameters>]
DESCRIPTION
The Test-AzureTrafficManagerDomainName cmdlet checks whether a domain name is available as a Microsoft Azure
Traffic Manager profile. If the domain name is available, this cmdlet returns a value of $True.
Or you could use a rest call to this endpoint:
https://management.core.windows.net/SUB_GUID/services/WATM/operations/isavailable/%NAME%.trafficmanager.net

New-AzureRmDnsZone cmdlet do not able to find resource group

I created a DNS Zone and a custom resource group 'Default-DNS-Zone' from portal but on shell prompt, executing below command throws Default-DNS-Zone not found. I still was able to do it from portal again.
PS C:\HBala> New-AzureRmDnsZone -Name www.example.com -ResourceGroupName Default-DNS-Zone
New-AzureRmDnsZone : ResourceGroupNotFound: Resource group 'Default-DNS-Zone' could not be found.
At line:1 char:1
Would it be anything to do with the OS support for the cmdlet? I use Windows 7.
If you're convinced that you are using the correct resource group name and subscription (please double-check!) then the next step should be to raise a Support ticket so the issue can be assigned to an engineer for further investigation.

Resources