https://pulumi.com logo
Title
w

wonderful-motherboard-66151

03/29/2022, 8:34 AM
Has anybody an example on setting up a mysql server on azure along with a few databases? I am trying to do that, but I keep getting an error like the following, and I have no idea where to look…
error: Could not connect to server: Error 9999: An internal error has occurred. Please retry or report your issues.
I just found a few resources explaining some SSL stuff… But even if I disable SSL I get the same error…
Ah, and by the way, I am using the
@pulumi/azure-native
and
@pulumi/mysql
packages… The problem only appears with the defined objects from
@pulumi/mysql
And I know that I can create databases using
@pulumi/azure-native
, but I also want to add users and grant them some permissions, which seems to be only possible with `@pulumi/mysql``
b

billowy-army-68599

03/29/2022, 1:31 PM
is your database accessible from where you're running pulumi from?
w

wonderful-motherboard-66151

03/30/2022, 7:16 AM
@billowy-army-68599 I am running pulumi on my local machine, and there I can access it via the
mysql
command on the command line
Is it save to paste the output from
pulumi up -d
in here? Secrets should not be shown there, right? Maybe that would help finding the error?
b

billowy-army-68599

03/30/2022, 3:22 PM
you would need
pulumi up -v=9 --logtostderr
w

wonderful-motherboard-66151

03/30/2022, 5:36 PM
It just seems to time out, from what I see there is no helpful log message…
Just to give you a gist: I create a database like that:
const databaseServer = new dbformysql.Server(
	key,
	{
		properties: {
			administratorLogin: config.requireSecret("database_user"),
			administratorLoginPassword: databaseRootPassword,
			createMode: "Default",
			sslEnforcement: "Disabled", // TODO should not be necessary
			storageProfile: {
				storageAutogrow: "enabled",
				storageMB: 5120,
			},
			version: "8.0",
		},
		resourceGroupName: resourceGroup.name,
		sku: {
			name: "B_Gen5_1",
		},
	}
);
Then I added a few firewall rules, so that it is accessible from my local machine, on which I also run
pulumi up
Afterwards I create mysql provider:
const mysqlProvider = new mysql.Provider('mysql', {
	endpoint: databaseServer.fullyQualifiedDomainName as pulumi.Output<string>,
	username: databaseServer.administratorLogin as pulumi.Output<string>,
	password: databaseRootPassword,
});
Then I try to create a database as follows (this is the first thing not working):
const database = new mysql.Database(
		databaseName,
		{
			name: databaseName,
		},
		{
			provider: mysqlProvider,
		}
	);
@billowy-army-68599 Am I making some kind of stupid beginner’s error?
b

billowy-army-68599

03/30/2022, 5:45 PM
you can reach the database with netcat/telnet the mysql command line from the box you're running Pulumi from?
w

wonderful-motherboard-66151

03/30/2022, 5:49 PM
I am running the command on my local machine, where I can access the database using the
mysql
command. Is that enough? Or do I have to use netcat/telnet? And I am going to doublecheck, tried quite some stuff until now 😄
Yeah, using the
mysql -h <host> -u <user> -p
command works
(Have neither netcat nor telnet installed, would that make a difference?)
It does not matter that I am using the pulumi service, right? The way I understood it, the communication with azure is happening via my machine anyway.
@billowy-army-68599 If that does not help at all, I am happy to create a (minimal) repro github repository for you to try
b

billowy-army-68599

03/30/2022, 5:57 PM
can you share the code you used to define the database too?
There’s no other object created by me that I would call a database 🙂
b

billowy-army-68599

03/30/2022, 6:06 PM
ah i see now
const mysqlProvider = new mysql.Provider('mysql', {
	endpoint: databaseServer.fullyQualifiedDomainName as pulumi.Output<string>,
	username: databaseServer.administratorLogin as pulumi.Output<string>,
	password: databaseRootPassword,
});
Can you try defining the provider with hardcoded values instead of the outputs, to eliminate that from the equation
w

wonderful-motherboard-66151

03/30/2022, 6:10 PM
It’s running, but the username changed… Is it possible that the
administratorLogin
returned is missing the part after the
@
that is shown in portal.azure.com? 🤔
Yeah, that seems to be the issue… Thought the
administratorLogin
would contain the correct username and that I would get a more specific error if the credentials are wrong…
b

billowy-army-68599

03/30/2022, 6:14 PM
you shouldn't need to cast as
pulumi.Output<string>
btw, but glad that helped figure it out. you can use
pulumi.interpolate
to add the
@
w

wonderful-motherboard-66151

03/30/2022, 6:17 PM
Had to cast it, because the return type of administratorLogin seems to be `Output<string|undefined>`…
Will try to get it running and get back to you 🙂
b

billowy-army-68599

03/30/2022, 6:19 PM
oh, just ensure it's defined with
!
w

wonderful-motherboard-66151

03/30/2022, 6:22 PM
With interpolate it’s not necessary anymore anyway 🙂 But I was also confused by the fact that it can be undefined… Is that a peculiarity of azure?
But anyway, thank you very much for your help!
b

billowy-army-68599

03/30/2022, 6:23 PM
yup, that's coming from the azure api definition