I am writing powershell script for capture OS-disk snapshot for Azure VM but While configuring snapshot I am getting some error.
I am using below command to create snapshot.I am using managed disk.
New-AzSnapshotConfig -OsType Linux -CreateOption copy -SourceUri Microsoft.Azure.Management.Compute.Models.OSDisk -DiskSizeGB 40 -Location 'East US'
Not sure how to do that. If anyone could you please help me to solve this issue.
OUTPUT
WARNING: Breaking changes in the cmdlet 'New-AzSnapshotConfig' :
WARNING: - "The output type 'Microsoft.Azure.Commands.Compute.Automation.Models.PSSnapshot' is changing"
- The following properties in the output type are being deprecated :
'EncryptionSettings'
- The following properties are being added to the output type :
'EncryptionSettingsCollection' 'HyperVGeneration'
WARNING: NOTE : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in
Azure PowerShell.
ResourceGroupName :
ManagedBy :
Sku :
TimeCreated :
OsType : Linux
HyperVGeneration :
CreationData : Microsoft.Azure.Management.Compute.Models.CreationData
DiskSizeGB : 40
EncryptionSettingsCollection :
ProvisioningState :
Id :
Name :
Type :
Location : East US
Tags :
EncryptionSettings :
Thanks
Rohit
Did you go to the link provided in the warning note? It says very clearly:
How do I get rid of the warnings?
To suppress these warning messages, set the environment variable 'SuppressAzurePowerShellBreakingChangeWarnings' to 'true'.
Set-Item Env:\SuppressAzurePowerShellBreakingChangeWarnings "true"
The error message is trying to tell you that the property EncryptionSettings you see in the output you provided will soon be changing from a single property of some type, to a collection property that you would have to iterate over to find all of the settings. They are trying to let you know that if you are capturing the output of New-AzSnapshotConfig to a variable and then calling $variable.EncryptionSettings, your code will work for now, but in the next breaking change release, that call will stop working. Most likely, since that property will no longer exist, the result of that call will simply be a $NULL.
So suppress this warning at your own risk because Microsoft is trying to do you a service here and let you know that if you don't do something about this your code could break. But if you are certain that you never reference property then you have nothing to worry about.
Related
Trying to limit the network bandwidth for a certain application, I came across such a thing as NetQosPolicy. I started trying to create new policies through PowerShell, but kept getting this error:
New-NetQosPolicy : New-NetQosPolicy : Invalid namespace string:1 character:1 + New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -Net ... + + CategoryInfo : MetadataError: (MSFT_NetQosPolicySettingData:ROOT/StandardCi...licySettingData) [New-Net QosPolicy], CimException + FullyQualifiedErrorId : HRESULT 0x8004100e,New-NetQosPolicy
I used this code: New-NetQosPolicy -Name TestPolicy -IPProtocolMatchCondition Both -NetworkProfile All -ThrottleRateActionBitsPerSecond 1200000
I thought I had made a mistake in the syntax and decided to look at the examples on the Microsoft website (https://learn.microsoft.com/en-us/powershell/module/netqos/new-netqospolicy?view=windowsserver2022-ps), but even their examples cause me the same error.
I haven't found a solution to this problem anywhere, so I'm asking on the forum. I will be grateful to anyone who knows how to solve this problem.
(By the way, I get the same error when I try to use the NetSecurity module (for example, the command: New-NetFirewallRule))
You might have a corrupt wmi repo, read this page but start with this check
Check if the repository is corrupted or not by running following command from command prompt with admin rights: winmgmt /verifyrepository
When I run the "Get-VisualStudioTemplate" command in a NuGet Powershell window in Visual Studio 2019, I'm getting an error that property "FullName" cannot be found on the object. I'm attempting to get the "EmptyWebApplicationProject40.vstemplate" in the C# format. I confirmed the template name was correct in the default template set, so I'm not sure where this error would be coming from.
I am using PowerShell ISE. When I run Add-AzureDisk
I get a CLI wizard and fill in the DiskName
and I have the vhd file uri in my clipboard (copied from the portal)
When I use the uri without "..." I get:
Add-AzureDisk : Invalid URI: cannot parse the hostname.
At line:1 char:1
Add-AzureDisk
~~~~~~~~~~~~~
CategoryInfo : NotSpecified: (:) [Add-AzureDisk], UriFormatException
FullyQualifiedErrorId : System.UriFormatException,Microsoft.WindowsAzure.Commands.ServiceManagement.IaaS.AddAzureDisk
Command
When I do use the "uri here" I get:
Add-AzureDisk : Invalid URI: URI-scheme is invalid. At line:1 char:1
I used this button:
I started to think that my powershell modules are out of date or something, so I ran Get-Module AzureRm.Profile -ListAvailable as suggested here:
Directory: C:\Program Files (x86)\Microsoft SDKs\Azure\PowerShell\ResourceManager\AzureResourceManager
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 4.0.0 AzureRM.Profile {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave,...
But I also have v5 (found this on the docs website):
Get-Module -ListAvailable -Name AzureRm.Resources | Select Version
Version
5.0.0
As you might have guessed, I am more used to the webportal. But I am trying to create a new vm with two unmanaged disks vhd's which are in my blob storage container.
Edit I tried the Azure CLI:
az vm create -n "tmp-vm" -g "resource-tmp" --attach-os-disk "https://the-uri-copied-from-ui.blob.core.windows.net/vhd-container/vm-osdisk.vhd" --size Standard_DS1_v2 --use-unmanaged-disk --os-type windows
and got:
At least one resource deployment operation failed. Please list deployment operations for details. Please see https://aka.ms/arm-debug for usage details.
{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"message": "The resource operation completed with terminal provisioning state 'Failed'.",
"details": [
{
"code": "DiskBlobPendingCopyOperation",
"message": "Disk blob https://the-uri-copied-from-ui.blob.core.windows.net/vhd-container/vm-osdisk.vhd is not ready. Copy state: Failed. Please retry when the blob is ready."
}
]
}
} Correlation ID: 0e1231a9-aa0e-4d79-8953-92ea43c658eb
I created the vhd with the powershell commands that I have found here:
https://stackoverflow.com/a/45569760/169714 perhaps that failed? I did not got an error or anything? How can I consolidate it?
edit2 I tried both templates and had a hard time getting the debug info. But I have found the error now. And it is the same as before:
The blob seems to have the expected size. The lease state says available. Last modified date is a second ago, so does that mean that the underlying storing is still in process? I tried to run Get-AzureStorageBlobCopyState -Blob tmpvmosdisk.vhd -Container vhd-containers -WaitForComplete but that gives an error about a non required (and unknown to me) argument:
Get-AzureStorageBlobCopyState : Could not get the storage context. Please pass in a storage context or set the current storage context.
edit 3 data disk seems flushed again. It was 512gb and is now back to zero?
so I got the not ready message again when I wanted to add the vhd as disk...
As Hannel said, Add-AzureDisk is a classic command. You could not use it to create a ARM mode VM.
--attach-os-disk it requires a managed disk, now, you give a unmanaged disk(VHD), so, you get the error log. See this link.
According to your scenario, the easy way is to create VM with a template. You could use this template:Create a Virtual Machine from a User Image.
If you have existing VNet, you also could use this template.
I can highlight multiple issues, i will try to answer all as best as i can.
First, Add Add-AzureDisk is a ASM (Classic Deployment) command but you are mentioning AzureRM Module. Is it an ARM or ASM deployment?
Second, you CLI is ARM deployment, that failed because you copied the VHD and the copy operation is not yet done so you cannot used the VHD. You should be able use the az storage blob show command to validate the VHD copy/move is completed before using VHD.
Hope this helps.
My question regards updating the configuration for a Service Fabric standalone Windows cluster.
What is the difference between ServiceFabricClusterConfiguration and ServiceFabricClusterManifest?
Suppose that I want to change the ApplicationPorts setting, I see these options:
Using ServiceFabricClusterConfiguration
use Get-ServiceFabricClusterConfiguration
edit the JSON file
Start an upgrade using Start-ServiceFabricClusterConfigurationUpgrade
or
Using ServiceFabricClusterManifest
Use Get-ServiceFabricClusterManifest
edit the XML file
Start an upgrade using
Register-ServiceFabricClusterPackage -Config -ClusterManifestPath "ClusterConfigv2.xml"
Start-ServiceFabricClusterUpgrade -ClusterManifestVersion 2 -Config
I tried to change ApplicationPorts via the ServiceFabricClusterManifest. We are now in a situation that the ApplicationPorts is different in the json (Get-ServiceFabricClusterConfiguration) than the value in the XML (Get-ServiceFabricClusterManifest)
My questions are:
What is the difference between the two approaches?
What is the approach I should take?
Since the different Get- commands give different results, which is the way to see the actual applied configuration?
update:
I get the following error when I run the Start-ServiceFabricClusterConfigurationUpgrade command.
Exception : System.Exception: Exception of type 'System.Exception' was thrown.
at System.Fabric.Interop.NativeClient.IFabricClusterManagementClient7.EndUpgradeConfiguration(IFabricAsyncOperationC
ontext context)
at System.Fabric.Interop.Utility.<>c__DisplayClassa.<WrapNativeAsyncInvoke>b__9(IFabricAsyncOperationContext context
)
at System.Fabric.Interop.AsyncCallOutAdapter2`1.Finish(IFabricAsyncOperationContext context, Boolean expectedComplet
edSynchronously)
TargetObject : Microsoft.ServiceFabric.Powershell.ClusterConnection
CategoryInfo : NotSpecified: (Microsoft.Servi...usterConnection:ClusterConnection) [Start-ServiceFa...gurationUpgrade], Exception
FullyQualifiedErrorId : StartClusterConfigurationUpgradeErrorId,Microsoft.ServiceFabric.Powershell.StartClusterConfigurationUpgrade
ErrorDetails :
InvocationInfo : System.Management.Automation.InvocationInfo
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {}
PSMessageDetails :
For on premises deployments Start-ServiceFabricClusterConfigurationUpgrade is the supported mechanism and is the only one you should use. As long as you use only one mechanism you shouldn't receive inconsistent results.
The detailed error is in the trace logs. Could u provide the 2 JSON files? Also, a common error is to upgrade without updating the json config version, which is the "clusterConfigurationVersion" item on the JSON config.
When we set breakpoints within a Module we've imported the debugger ignores the breakpoint. Has anybody else seen this behaviour?
This is driving me nuts, we use PowerShell Modules extensively.
The thing that's really weird is I can see the breakpoint if I run get-psbreakpoint
PS H:\Projects\Powershell> get-psbreakpoint | format-list -force
Id : 0
Script : H:\projects\Powershell\Shared\SFTP\SFTP.psm1
Line : 25
Column : 0
Enabled : True
HitCount : 0
Action :
Id : 1
Script : H:\projects\Powershell\Trading\CPPIB\scripts\CppibBorrowReturns.ps1
Line : 12
Column : 0
Enabled : True
HitCount : 1
Action :
EDIT: Seems to work if I delete the psd1 (Manifest file)
Debugging modules can be tough. One way I have been able to do it is load both the module and the code that calls the function you are debugging. In the code that calls a function in the module, place a break point. Then when it its the call to the function in the module, step in to it. Once it steps into the module you should be able to hit F5 again to hit your break point in the module.
Sorry if that is not as clear as it should be, still reeling from day light savings on a Monday.