Error while adding VHD as OS Disk in resource manager - powershell

I am trying to create VM using existing VHD which I have on the storage blob.
I ran the below command
Add-AzureDisk -DiskName "Keldc1" -MediaLocation "https://*****.blob.core.windows.net/essrestore/Kel-DC01201611012647.vhd" -Label "Bootdisk" -OS "Windows"
the error i reeived is
Add-AzureDisk : BadRequest: The storage account with the name ***** as specified in the VHD URI
https://*****.blob.core.windows.net/essrestore/Kel-DC01201611012647.vhd does not exists in the current subscription
I verified I have the subscription is correct and the Storage account is in the same subscription.
Help Please.

You probably created Your resources in the new portal, however You could be executing commands on the classic one. Try this,
azure login
azure config mode arm
This will execute the commands on the new portal.

Check with the
Get-AzureSubscription -Current
the current subscription. If that is different from the subscription you are going to use for your disk, use
Select-AzureSubscription -SubscriptionId "id"
and execute the commandlet again.
Basically, it checks if there is the storage account specified in your string in the currently used Azure account, and if not, throws the error.
Just checked - it should work if the right subscription is selected and there is the storage account in that.

Related

Enabling public access to SQL Server in Azure devops release pipelines

In order to run migrations on my Test Azure SQL which is configured with PrivateLink I temporarly enable public access and then disable it again.
Set-AzSqlServer
-ServerName $sqlServerName
-ResourceGroupName $(IntegrationResourceGroupName)
-PublicNetworkAccess "Enabled"
And it worked for months, but recently I started receiving this error message.
Cannot find the Azure Active Directory object 'My_DB_Admins_Group_Name'.
Please make sure that the user or group or application you are authorizing is registered
in the current subscription's Azure Active directory. To get a list of Azure Active Directory
groups use Get-AzADGroup, or to get a list of Azure Active Directory
users use Get-AzADUser or to get a list of Azure Active Directory applications use Get-AzADApplication.
Release pipeline was not modified. What might be the reason?
I can execute this PS command from my local machine, as me, and it works fine.
As per the error message : Only azaduser and azadgroup are filtered by azsqlserveractivedirectoryadministrator. It is unlikely that it will look for service principles. You might make an azure ad group called dbas or something similar. To that group, then add the service principal to it.
Then add the group to the sql server using that set-azsqlcommand
$sp = Get-AzADServicePrincipal -DisplayName "theserviceprincipalname"
Add-AzADGroupMember -MemberObjectId $($sp.id) -TargetGroupDisplayName "AAD Group Name"
Set-AzSqlServerActiveDirectoryAdministrator -ResourceGroupName 'data-eastus2' -ServerName 'data-eastus2-sqlsvr' -DisplayName "AAD Group Name"

Get-AzureRmBackupVault not returning any error or result

Still wondering why Azure Powershell is not consistently working.
I tried pulling all azure vault via powershell using following command line but none of result coming from this command :
Add-azurermaccount
Login-AzureRmAccount
Select-AzureRmSubscription -SubscriptionId "XXXXX-b8ee-4533-a2c2-3ee6b4f01a8d"
Get-AzureRmBackupVault
Same problem with many other powershell command like Get-AzureRmResourceGroup where otherside Get-AzureRmVM working fine.
Please ensure you have a Backup vault (classic) in your subscription.
Backup Vault is a classic resource, if you create Recovery Services vault,
please execute following cmdlet.
Get-AzureRmRecoveryServicesVault
More information about this please refer to this link.
Note: You could not use Get-AzureRmBackupVault to get Recovery Sevices Vault . It seems that you don't have backup vault(classic) in your subscription.
If you have Backup vault in your subscription, you could download and install the latest version Azure Power Shell from the link.

Azure PowerShell - Selecting Subscription

I need to select my Azure Subscription in Azure PowerShell.
I copy/paste the Subscription ID (to ensure no typos) from the Azure Management Portal, it's a hex-string:
When I run:
Select-AzureSubscription -SubscriptionId '0300...'
I get an error message:
Select-AzureSubscription : The subscription id 0300... doesn't exist.
I know my subscription ID is correctly copied from the settings in Azure Management Portal, I even did a BeyondCompare to make sure.
I'm wondering about security... am I missing something? Do I need to somehow provide my Azure credentials? It wouldn't make sense to just allow anyone to select any Azure subscription, unless the Subscription ID is supposed to be super-secret, like an SSN.
You need to log on to your Azure account first:
To start working with the Azure Service Management cmdlets, first log
on to your Azure account. To log on to your account, run the following
command:
Add-AzureAccount
After logging into Azure, Azure PowerShell creates a context for the
given session. That context contains the Azure PowerShell environment,
account, tenant, and subscription that will be used for all cmdlets
within that session. Now you are ready to use the modules below.
Source: https://learn.microsoft.com/en-us/powershell/azure/install-azure-ps?view=azuresmps-3.7.0

New-AzureReservedIP : No default subscription has been designated

I never used Azure PowerShell before, but now I'm running a command to have Azure reserve a static IP address:
New-AzureReservedIP –ReservedIPName "137.117.11.18" –Label "people-dns-ip" –Location "US West"
And then I'm getting this error: New-AzureReservedIP : No default subscription has been designated.
So, I was trying to figure out what is the or just set to default... using the command Select-AzureSubscription I can see that The subscription name BizSpark doesn't exist.
Not sure how to print the value of Get-AzureSubscription on the screen, but in my Azure portal is says: SUBSCRIPTION NAME BizSpark
Any idea how to resolve this? or maybe this option is limited for BizSpark users??
To use Azure Powershell at very first you should use
Add-AzureAccount
it will give you a popup where you can login with you azure credentials. this way you will connect to your Azure subscription in Azure Powershell
Need to add your azure account to be able to manage assets:
If for some reason method 1 doesn't work, try method 2.
Method 1:
At powershell, run:
Add-AzureAccount
Method 2:
At powershell, run:
Get-AzurePublishSettingsFile
Sign in to the Windows Azure Management Portal, and then follow the instructions to download your Windows Azure publishing settings.
Again at powershell, run:
Import-AzurePublishSettingsFile <mysettings>.publishsettings
Replace with the file name of the publishsettings file that you downloaded in the previous step and correct the path if necessary.

Azure Runbook: The subscription named 'xxx' cannot be found

I'm trying to compose a Azure Runbook for starting an Azure Website but keep getting the following two errors
Select-AzureSubscription : The subscription named
'vslaazuresubscription' cannot be found. Use Set-AzureSubscription to
initialize the subscription data.
Start-AzureWebsite : No current subscription has been designated. Use
Select-AzureSubscription -Current to set the
current subscription.
My Runbook is as follows
My Assets are as follows
I was trying to follow the SO Answer here to no avail. I have checked that
I have a subscription by that name
The admin#vslaactivedirectory.onmicrosoft.com exists in active directory configured for the subscription.
Please help. Thanks in advance.
Are you sure "vslaazuresubscription" is the name of your Azure subscription, and that admin#vslaactivedirectory.onmicrosoft.com is configured as an admin of the vslaazuresubscription subscription?
If you run Get-AzureSubscription after Add-AzureAccount, does it output vslaazuresubscription as one of the available subscriptions?