Can't find my SQL server instance in Azure - azure

I'm having problems finding a SQL server in Azure portal. The SQL server is apparently running as I can connect to it with both AzureAD credentials and SQL credentials via SSMS. The apps using databases from the SQL server is also working.
But I can't find it in Azure? I've tried checking portal.azure.com with all our logins, but no luck.
Anyone has any tips?

Double check if you have chosen the same directory and subscription under you account if you have more than one. And If you remember your resource group name, just to rule out any transient issue in web portal, you can try the below:
Install Azure CLI from here or use cloud CLI and run below commands in order
Login to your account, result lists all the subscription in your account.
az login
Verify your preferred subscription is set
az account show
See your SqlDB details:
az sql db show --name YourSqlDbName --server YourSqlServerName --resource-group YourResourceGroupName
You'll see all he details, if it exists.

Turns out I had to log in with my admin account and go to portal.azure.com/customer.domain

Related

Az login Fails using Personal Microsoft Account - AADSTS500200

For a long time was using Terraform with Azure and it worked fine. Now for any reason the az cli command it doens't work.
I'm getting follow error:
AADSTS500200: User account 'xxxx ' is a personal Microsoft account. Personal Microsoft accounts are not supported for this application unless explicitly invited to an organization. Try signing out and signing back in with an organizational account.
I've already upgrade az cli versin to 2.42 but problem perists. Even using incognito mode couldn't login to Azure.
Instead of using az login, via browser I'm able to login to azure cloud without issues.
The problem was related with Az cloud list. The active azure cloud was "AzureUSGovernment" instead of "AzureCloud". Once enabled "AzureCloud" issue got fixed.
az cloud set --name AzureCloud
Try the below commands to clear the cache.
az account clear
az login
or
az login --tenant [tenant id]

Why "az mysql server list" is giving me an empty array in azure CLI

I am quite new to Azure, I wanted to list all the mysql servers present in my subscription but when I try running above command. It is returning an empty array even though I have got one sql server in my azure.
I tried these two commands in both azure portal CLI and local powershell and both of them are giving me an empty array.
az mysql server list
az mysql server list -g resourcegroupname
Thanks in advance !
If you have one Azure SQL server instance in your Azure subscription and you want to list it by Azure Cli, you should use the command below:
az sql server list
Details see here.
Azure MySQL is another kind of SQL service.

Unable to connect SQL Azure through Access Token generated through bearer token

I was trying to connect my SQL Azure Queries through Bearer token which is generated through this query
$token= & az account get-access-token --resource=https://database.windows.net/ --query accessToken
Since today it says "Login failed for user ''"
I have not done any major changes in my environment, as even locally the script does not work
Once i get the access token then I Connect SQL server, Firewall settings are all fine. I am the server Admin of my DB, Is there something which i check further ?
I think the token it's expired.
As per the doc az account get-access-token: The token will be valid for at least 5 minutes with the maximum at 60 minutes.
Please try to re-generate a new one, and give it a try.
I was executing the script from DevOps pipeline as a Task of Azure CLI.. So i had used service principal (connection string) as an Admin in SQL Server from Azure Portal manually. It was working fine
When i tried to Automate the same by adding Service Principal as an administrator through ARM template, it showed it had applied the same in Azure portal, but when executing the pipeline it said login failed
So to resolve the issue I had to manually apply service principal as an Admin in Azure portal

Using Azure API without login (using roles)

I'm trying to list virtual machines in azure from inside another virtual machine in azure. I mean, what I want to do is list backend members from the frontent. BUT I don't want to use credentials in my front end and I want to use roles.
For example, in AWS you can assign roles (EC2::DescribeInstance) to instances and use this command:
aws ec2 describe-instances --query 'Reservations[].Instances[].[PrivateIpAddress]' --output text --filters Name=instance-state-name,Values=running Name=tag:myapp-member,Values=myapp-backend
I can run that command without expose my credentials in any place.
If I run something like this on Azure
az vm list
It says I need to login first.
And I can't find how to assign roles to the instance.
Thanks a lot
Cheers
For your purpose, you can use the VM Managed Identity to log in for the Azure CLI, this way will not store any credential in the VM. But first, you need to assign the roles to your VM. And to assign the roles, you can use the Azure CLI command az role assignment create and the steps in Assign a managed identity access to a resource using Azure CLI. Or just in the Azure Portal, you can follow the steps in Assign a managed identity access to a resource by using the Azure portal. The PowerShell command is also available.
When the role is created, you can use the Azure CLI command az login --identity to log in without credential.
Note: You need to install the Azure CLI in the VM first.

Using azure cli from virtual machine

I need to use the azure cli from within a linux virtual machine. There are two contraints:
cannot use/store the credentials used for creating the VM on the VM.
the login/authentication need to be automated (non-interactive)
On AWS, I can use instance profiles for such scenario, but I am unable to find any feasible approach for Azure. Any help is greatly appreciated.
If you are using Azure CLI 2.0, you can use az login with the --msi parameter to log in using the Virtual Machine's identity. See the az login documentation for more information.
az login —msi has been deprecated (See here) as of v2.0.22.
The new method is to use the —identity option. ie. az login —identity. See az login docs for more information.
This is how it was resolved for me ,
you need to be logged in to azure portal in your browser
type az login --use-device-code in your ssh terminal
It gives you a URL and a code , enter the URL in the same browser that you were logged in to azure portal and enter the code in the pop up window
choose your email user for the azure portal in the next window and
you will be logged in to azure cli in your ssh terminal

Resources