Has anybody an example on setting up a mysql serve...
# getting-started
w
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…
Copy code
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
is your database accessible from where you're running pulumi from?
w
@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
you would need
pulumi up -v=9 --logtostderr
w
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:
Copy code
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:
Copy code
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):
Copy code
const database = new mysql.Database(
		databaseName,
		{
			name: databaseName,
		},
		{
			provider: mysqlProvider,
		}
	);
@billowy-army-68599 Am I making some kind of stupid beginner’s error?
b
you can reach the database with netcat/telnet the mysql command line from the box you're running Pulumi from?
w
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
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
ah i see now
Copy code
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
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
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
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
oh, just ensure it's defined with
!
w
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
yup, that's coming from the azure api definition