That code works based on my test, I can update connection string and set credential with your code.
Before everything, ensure that you can connect to the target Azure SQL DB in SQL Server Management Studio.
Then debug what you've set the correct connection string. normally a connection string is like
{"connectionString":"data source=MyAzureDB.database.windows.net;initial catalog=Sample2;persist security info=True;encrypt=True;trustservercertificate=False"}
By the way, is the Power BI workspace collection and the Azure SQL database in the sample subscription? If not and you can confirm that the connection string is correct, try to set the Azure SQL database firewall as below for testing purpose.