I'm trying to set Azure diagnostics on a deployed cloud service using the Azure Powershell cmdlets and the Set-AzureServiceDiagnosticsExtension command:
Set-AzureServiceDiagnosticsExtension -StorageContext $storageContext -DiagnosticsConfigurationPath $diagnosticsConfiguration.FullName -ServiceName $serviceName -Slot Production -Role "MyService.Web"-Verbose
Doing so I get the following error
Exception: Microsoft.WindowsAzure.CloudException: BadRequest: The extension ID
MyService.Web-PaaSDiagnostics-Production-Ext-0 is invalid.
at Microsoft.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)
at Microsoft.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccess(Task
task)
at Microsoft.WindowsAzure.HostedServiceOperationsExtensions.AddExtension(IHo
stedServiceOperations operations, String serviceName,
HostedServiceAddExtensionParameters parameters)
at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.ExtensionMan
ager.AddExtension(HostedServiceAddExtensionParameters extensionInput)
at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.ExtensionMan
ager.InstallExtension(ExtensionConfigurationInput context, String slot,
ExtensionConfiguration extConfig)
at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServ
iceDiagnosticsExtensionCommand.ExecuteCommand()
at Microsoft.WindowsAzure.Commands.ServiceManagement.Extensions.SetAzureServ
iceDiagnosticsExtensionCommand.OnProcessRecord()
at Microsoft.WindowsAzure.Commands.Utilities.Common.CloudBaseCmdlet`1.Proces
sRecord()
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
tion
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
n,UpdateDiagnosticsBuildStep.ps1
It works when I don't use the "-Role" parameter but then I have to call Remove-AzureServiceDiagnosticsExtension for each role prior to calling the Set command which adds 2-3 minutes per role to the script execution time.
The Role parameter matches my role name in the Azure Cloud Service. Am I doing something wrong?
This doesn't like . in the Role name
Change to underscore and it will work
Its a bug in powershell that they will fix next time
Related
$storageAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup -Name "blobstgaccdemo" -SkuName Standard_LRS -Location $location
New-AzStorageAccount : An error occurred while sending the request.
At line:1 char:19
+ ... geAccount = New-AzStorageAccount -ResourceGroupName $resourceGroup -N ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzStorageAccount], HttpRequestException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Management.Storage.NewAzureStorageAccountCommand
This is a generic error and can occur in more than a few conditions, including when Azure PowerShell is not able to reach/resolve the underlying management REST APIs, or in case of SSL errors.
To get more information about the error, run the PS cmdlet passing the -Debug parameter along, or set $DebugPreference to Continue before executing the cmdlet. This would surface the details of the exception along with the stack trace.
If this is consistently happening with other cmdlets as well, then you could try upgrading PS modules, or re-installing Azure PowerShell itself. Another quick alternative would be to use Azure Cloud Shell that is preconfigured with all the required modules.
We have a Cloud Service (Classic) swap using powershell in Azure pipelines that has worked all year, setup by a previous employee and now it is failing with error:
Move-AzureDeployment : An error occurred while sending the request.
At D:\a\_temp\blahblahblah.ps1:8 char:1
+ Move-AzureDeployment -ServiceName $servicename
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Move-AzureDeployment], HttpRequestException
+ FullyQualifiedErrorId : System.Net.Http.HttpRequestException,Microsoft.WindowsAzure.Commands.ServiceManagement.H
ostedServices.MoveAzureDeploymentCommand
The actual job task is using PowerShell Script set as inline with Error action as Stop. The actual script:
$subid = 'blah-blah-blah-blah'
$servicename = "blahblahblah"
Select-AzureSubscription -SubscriptionId $subid
Move-AzureDeployment -ServiceName $servicename
$service = Get-AzureDeployment -ServiceName $servicename -Slot Production
Start-Sleep -s 300
Remove-AzureDeployment -ServiceName $servicename -Slot "Staging" -Force
I was sure this was maybe a Service connection with Management Certificate expired but I have one valid working and found it is setup exactly like another similar pipeline/service connection that is working.
So the issue was two things, SSL and PowerShell version issues after updates. To deal with SSL issues I added this line to the top of our inline script:
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
And for the PowerShell issue it required changing to the Azure PowerShell app for pipelines, so we could roll back to a specific task version and the 4.2.1 PowerShell Version as seen in this answer:
Programmatically Swap Staging Slot to Production Slot in Azure Cloud Service
This might be the only way to swap a Cloud Service (Classic) these days. A little annoying Azure pushed this classic service and never properly maintained it.
I'm trying to create Azure Service Bus using Azure powershell command.
I'm using command as :
New-AzureSBNamespace –Name UKBProjectServiceBus -Location "West US" -CreateACSNamespace $true -NamespaceType Messaging
But getting exception as:
New-AzureSBNamespace : InternalError: The server encountered an internal error. Please retry the request.
At line:1 char:1
+ New-AzureSBNamespace -Name UKBProjectServiceBus -Location "West US" - ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureSBNamespace], CloudException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceBus.NewAzureSBNamespaceCommand
Can anyone please help me?
This PowerShell command for Service Bus will no longer be supported on 11/1/2019. The Azure Service Management model is deprecated for Service Bus, and will be disabled on that date. Please use the commands which support the Azure Resource Management model in AzureRM.ServiceBus.
As Gaurav and Rohit said, the New-AzureSBNamespace is a really old Powershell Cmdlet to use.
You could use New-AzureRmServiceBusNamespace -ResourceGroup $ResGrpName -NamespaceName $Namespace -Location $Location to create Azure ServiceBus. Refer to this one.
Or use New-AzServiceBusNamespace -ResourceGroupName Default-ServiceBus-WestUS -Name SB-Example1 -Location WestUS to create Azure ServiceBus. Refer to this one.
I have a working azure arm powershell scripts to create a new virtual machine and it's working fine in cloud service but when I am trying to execute in azure webjob, I am getting following Error :
New-AzureRmResourceGroup -Name $resourceGroup -Location $location
New-AzureRmResourceGroup : The Win32 internal error "The handle is invalid"
0x6 occurred while setting character attributes for the console output buffer.
Contact Microsoft Customer Support Services.
At D:\local\Temp\jobs\triggered\webjob\v43suxvk.lln\testDrives\WindowsServer201
2\provision.ps1:17 char:1
+ New-AzureRmResourceGroup -Name $resourceGroup -Location $location
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmResourceGroup], Host
Exception
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.NewAzureResou
rceGroupCommand
so how can I run arm powershell scripts in webjobs?
I recently had to delete and re-install my VM due to an issue with the VM locking up. Now that the VM is back online, I noticed the shutdown automation is not working. It was working fine before I ran into the issue with the VM. Below is the PS script from the runbook, it returns the following error:
Correlation ID: 72fa8e58-89f1-4612-bc43-1b05876c2bff
Timestamp: 2015-08-25 06:04:14Z: The remote server returned an error: (401) Unauthorized.
At Shutdown:6 char:6
+
+ CategoryInfo : CloseError: (:) [Add-AzureAccount], AadAuthenticationFailedException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.Profile.AddAzureAccount
8/24/2015 11:04:25 PM, Error: Get-azurevm : No default subscription has been designated.
Use Select-AzureSubscription -Default <subscriptionName> to set the default subscription.
At Shutdown:8 char:8
+
+ CategoryInfo : CloseError: (:) [Get-AzureVM], ApplicationException
+ FullyQualifiedErrorId : Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.GetAzureVMCommand
Any idea what I am missing to get this working with new VM? I have been wracking my brain for something with the credentials that would not include this new VM, but have come up empty handed.
workflow Shutdown
{
$Cred = Get-AutomationPSCredential -Name "auto"
Add-AzureAccount -Credential $Cred
$vms = Get-azurevm
foreach($VM in $VMS)
{
$VMName = $VM.Name
Stop-AzureVM -ServiceName $VM.ServiceName -Name $VM.Name -Force
Write-Output "Shutting down VM : $VMName "
}
}
I think you should also add the subscription name (select-azuresubscription in the error log) in the script you are using. There are quite some examples of doing this in various ways in the TechNet Script libraries like this one https://gallery.technet.microsoft.com/scriptcenter/Stop-Azure-VM-with-OrgID-41a79d91
I created a new user, granted them admin rights to the subscription, and updated the credential. That seemed to fix it, guessing it was something with the existing co-admin account not having access to the new VM.