Code Monkey home page Code Monkey logo

azurepowershell's Issues

error at new storage account creation when cloning resource group in same subscription

Good morning,

We have been using the Clone-AzureRMresourceGroup.ps1 script to test the cloning of resource groups (production) to resource groups (accepting/testing).
The last test occured last summer. After that test run the original resource group was modified. The original resource group consisted of three vm's with a single disk and a fourth vm with an additional disk.
After modifications the resource group consisted of three vm's with a single disk and a fourth vm with three additional managed disks. After running the Clone-AzureRMresourceGroup.ps1 script on the modified resource group we ran into some issues regarding the cloning process.

The resource group is created but the storage account(s) are not. In order to troubleshoot the problem I created a simple testing resource in Azure (We use terraform the create resources in Azure).
I have listed what the powershell script does at first an also listed the error:

The following items will be copied:
Storage Accounts:
testing1201st1
Managed Disks:
Virtual Machines:
server1
server2
server3
server4
Operating system disks:
serverosdisk1
serverosdisk2
serverosdisk3
serverosdisk4
Data disks:
Current status of VMs:
server1 status is VM deallocated
server2 status is VM deallocated
server3 status is VM deallocated
server4 status is VM deallocated
Virtual networks:
cc-test
Network Security Groups:
nsg-test-server1
nsg-test-server2
nsg-test-server3
nsg-test-server4
Load Balancers:
Public IPs:
server1publicip
server1publicip
server1publicip
VERBOSE: Retrieving storage context for each source blob
Additional storage blobs:
VERBOSE: Creating new resource group clone_acceptatie in northeurope
The new resource group clone_acceptatie was created in subscription RelyTest01
VERBOSE: Creating storage account testing1201st1c1af887f in resource group clone_acceptatie at location northeurope
New-AzureRmStorageAccount : Cannot bind parameter 'EnableEncryptionService'. Cannot convert the "Microsoft.Azure.Manage
ment.Storage.Models.Encryption" value of type "Microsoft.Azure.Management.Storage.Models.Encryption" to type "System.Nullable`1[Microsoft.Azure.Commands.Management.Storage.StorageAccountBaseCmdlet+EncryptionSupportServiceEnum]".
At C:\Scripts\Clone-AzureRMresourceGroup.ps1:584 char:64

  • ... $newStorageAccount = New-AzureRmStorageAccount @storageParams -ea Sto ...
  •                                                ~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [New-AzureRmStorageAccount], ParameterBindingException
    • FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Management.Storage.NewAzureStora
      geAccountCommand

WARNING: Failed to create storage account. Storage account name testing1201st1c1af887f may already exists.
Enter a different Destination Storage Account Name: testing1201st2
VERBOSE: Creating storage account testing1201st2 in resource group clone_acceptatie at location northeurope
New-AzureRmStorageAccount : Cannot bind parameter 'EnableEncryptionService'. Cannot convert the "Microsoft.Azure.Manage
ment.Storage.Models.Encryption" value of type "Microsoft.Azure.Management.Storage.Models.Encryption" to type "System.Nullable`1[Microsoft.Azure.Commands.Management.Storage.StorageAccountBaseCmdlet+EncryptionSupportServiceEnum]".
At C:\Scripts\Clone-AzureRMresourceGroup.ps1:584 char:64

  • ... $newStorageAccount = New-AzureRmStorageAccount @storageParams -ea Sto ...
  •                                                ~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidArgument: (:) [New-AzureRmStorageAccount], ParameterBindingException
    • FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Azure.Commands.Management.Storage.NewAzureStora
      geAccountCommand

WARNING: Failed to create storage account. Storage account name testing1201st2 may already exists.
Enter a different Destination Storage Account Name:

It does not matter which storage account is entered, the same error keeps propping up. Is there something which has changed in Azure in the last six months regarding storage (and possibly storage encryption)?

Regards, Marvin Woods
Claranet Benelux, The Netherlands.

Unable to create destination storage account

When I need to create the destination storage account - it keeps failing:

New-AzureRmStorageAccount : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or
empty, and then try the command again.

$newStorageAccount = New-AzureRmStorageAccount $storageParams -e ...

  •                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [New-AzureRmStorageAccount], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.Management.Storage.NewAzureStorageAccountCommand

Migrating credentials failure

Hi, I am testing this script for an upcoming migration and get the error:
Enter credentials for the 'source' Azure Subscription...
WARNING: The provided credentials failed to authenticate or are not associcated to a valid subscription. Exiting the script
I have ensured that I have the correct credentials but to no avail - any assistance will be appreciated. Thank you.

Storage Account Encryption Error in Copy-AzureRMresourceGroup

The Copy-AzureRMresourceGroup.ps1 script gave me an error when attempting to create the storage account in the new resource group.

Looking at the source, I saw that the $EncryptionType variable wasn't used in the storage params. After updating the script to use this value the cmdlet ran without issue.

Multiple Script Errors when copying from a storage account

  1. Missing closing } starting at line 559
  2. Encryption piece errors out on parameters. It appears the latest version of New-AzureRMStorageAccount doesn't even take an encryption parameter. Commenting out this section has the script function until it gets to the final VM creation.
  3. New-AzureRmVM : Required parameter 'networkProfile' is missing (null).
    ErrorCode: InvalidParameter
    ErrorMessage: Required parameter 'networkProfile' is missing (null).
    StatusCode: 400
  4. Add-AzureRmVMDataDisk : Cannot validate argument on parameter 'VhdUri'. The argument is null or empty. Provide an argument that is
    not null or empty, and then try the command again.
  5. Copy-AzureRMresourceGroupv2.ps1:1581 char:21
  • ... $newNICs += Get-AzureRmNetworkInterface -Name $NICName -ResourceGroup ...
  •             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : CloseError: (:) [Get-AzureRmNetworkInterface], NetworkCloudException
    • FullyQualifiedErrorId : Microsoft.Azure.Commands.Network.GetAzureNetworkInterfaceCommand

For reference I am copying a vm attached to a storage account between subscriptions. It is a single linux vm with 1 extra data disk. I have run the Update-Module AzureRM command and am using the latest version of PowerShell. Any help would be appreciated.

Enhancements for copy-azureRMresourcegroup

To make this script more complete, we're looking for assistance in adding the ability to copy these resources and add Pester testing:

• Web Apps
• SQL Servers
• Azure Automation Accounts
• Copy v1 cloud services and VMs

Allow only lowercase characters and numbers in storage account name

Describe the bug
Only lowercase characters and numbers are allowed in storage account name. Currently when creating temporary storage account, resource group name is used. Creation of temporary storage account fails if the resource group has _ in it.

To Reproduce

  1. Pass resource group name with a _ in it.
  2. Try to clone the Resource group.

Expected behavior
A temporary storage account with resource group name as prefix is created.

Clone-AzureRMresourceGroup.ps1 fails at Set-AzureRmVMOSDisk if Linux VM

See Error:

Set-AzureRmVMOSDisk : Cannot validate argument on parameter 'ManagedDiskId'. The argument is null or empty. Provide an argument that is not null
or empty, and then try the command again.
At C:\Users\Calhoun.Clark\Documents\WindowsPowershell\scripts\AzurePowershell\Clone-AzureRMresourceGroup.ps1:1492 char:104

  • ... M $VirtualMachine -Name $OSDiskName -ManagedDiskId $osDisk.Id -Cachin ...
  •                                                    ~~~~~~~~~~
    

"$osDisk.Id" in above code line should be "$osDiskId"

Issues with New-AzureRmDisk when cloning with Module AzureRM 6.1.1

Hello @JeffBow
I have been using the Clone-AzureRMresourceGroup.ps1 script to successfully clone Resource Groups for over 6 months now.
Yesterday I updated Powershell Module AzureRM to version 6.1.1

Clone-AzureRMresourceGroup.ps1 has started failing when attempting to create a new managed Disk on the new resource group. This occurs for any attempt made.

New-AzureRmDisk : The request content was invalid and could not be
deserialized: Required property 'name' not found in 'sku'.
ErrorCode: InvalidRequestContent
ErrorMessage: The request content was invalid and could not be
deserialized: Required property 'name' not found in 'sku'.
StatusCode: 400
ReasonPhrase: Bad Request
OperationID : de9b7234-7a5f-4153-83bc-67c82374cd88
At C:\W_DRIVE\Azure Demo
Management\AzurePowerShell\Clone-AzureRMresourceGroup.ps1:760 char:27
+ ... newMDdisk = New-AzureRmDisk -ResourceGroupName $resourceGroupName
-Di ...
+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [New-AzureRmDisk], Compute
   CloudException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Compute.Automatio
   n.NewAzureRmDisk

I was able to reinstall module AzureRM 4.4.1 and is working with no issues.

I am not sure how to diagnose further?
Hoping can help - as I would like to use the latest version of AzureRM if possible.

Source Account Creds with access to multiple Tenants Breaks

I have an account which has access to 5 different Subscriptions across two AAD tenants. Line 286 is #$sub = Get-AzureRmSubscription -TenantID $login.context.Subscription.TenantID which passes a given Tenant ID for the source account. In my case, since I only had 1 Subscription in the AAD Tenant, I was never prompted for the Select-AzureRmSubscription dialogue. I removed the -TenantID flag which looks like this now: $sub = Get-AzureRmSubscription and it works fine.

How to run the scripts

I am new to Azure and we need to clone our production resource group to a testing resource group and I found this script you have for just that. But I have idea how to run it at Azure Cloud.

Error Running Copy-AzureRMresourceGroup.ps1

VERBOSE: Retrieving storage context for each source blob
You cannot call a method on a null-valued expression.
At C:\scripts\Copy-AzureRMresourceGroup.ps1:121 char:5

  • $split = $srcURI.Split('/')
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

Cannot index into a null array.
At C:\scripts\Copy-AzureRMresourceGroup.ps1:122 char:5

  • $strgDNS = $split[2]
    
  • ~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArray

You cannot call a method on a null-valued expression.
At C:\scripts\Copy-AzureRMresourceGroup.ps1:123 char:5

  • $splitDNS = $strgDNS.Split('.')
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : InvokeMethodOnNull

Cannot index into a null array.
At C:\scripts\Copy-AzureRMresourceGroup.ps1:124 char:5

  • $storageAccountName = $splitDNS[0]
    
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidOperation: (:) [], RuntimeException
    • FullyQualifiedErrorId : NullArray

Get-AzureRmStorageAccountKey : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At C:\scripts\Copy-AzureRMresourceGroup.ps1:130 char:107

  • ... GroupName $resourceGroupName -AccountName $StorageAccountName).Value[ ...
  •                                           ~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Get-AzureRmStorageAccountKey], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.Management.Storage.GetAzureSto
      rageAccountKeyCommand

New-AzureStorageContext : Cannot validate argument on parameter 'StorageAccountName'. The argument is null or empty.
Provide an argument that is not null or empty, and then try the command again.
At C:\scripts\Copy-AzureRMresourceGroup.ps1:131 char:67

  • ... w-AzureStorageContext -StorageAccountName $StorageAccountName -Storag ...
  •                                           ~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [New-AzureStorageContext], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.WindowsAzure.Commands.Storage.Common.Cmdlet.N
      ewAzureStorageContext

Get-AzureRmStorageAccount : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an
argument that is not null or empty, and then try the command again.
At C:\scripts\Copy-AzureRMresourceGroup.ps1:135 char:93

  • ... count -ResourceGroupName $resourceGroupName -Name $storageAccountName
  •                                                   ~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : InvalidData: (:) [Get-AzureRmStorageAccount], ParameterBindingValidationException
    • FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Azure.Commands.Management.Storage.GetAzureSto
      rageAccountCommand

Additional storage blobs:

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.