1414import com .microsoft .azuretools .ActionConstants ;
1515import com .microsoft .azuretools .authmanage .AuthMethodManager ;
1616import com .microsoft .azuretools .core .mvp .model .mysql .MySQLMvpModel ;
17- import com .microsoft .azuretools .telemetrywrapper .Operation ;
18- import com .microsoft .azuretools .telemetrywrapper .TelemetryManager ;
17+ import com .microsoft .azuretools .telemetry .TelemetryConstants ;
18+ import com .microsoft .azuretools .telemetrywrapper .*;
19+
20+ import java .util .Collections ;
21+ import java .util .Map ;
1922
2023public class AzureMySQLService {
2124 private static final AzureMySQLService instance = new AzureMySQLService ();
@@ -36,10 +39,11 @@ public Server createMySQL(final AzureMySQLConfig config) {
3639 final Operation operation = TelemetryManager .createOperation (ActionConstants .MySQL .CREATE );
3740 try {
3841 operation .start ();
39- String subscrptionId = config .getSubscription ().subscriptionId ();
42+ final String subscriptionId = config .getSubscription ().subscriptionId ();
43+ EventUtil .logEvent (EventType .info , operation , Collections .singletonMap (TelemetryConstants .SUBSCRIPTIONID , subscriptionId ));
4044 // create resource group if necessary.
4145 if (config .getResourceGroup () instanceof Draft ) {
42- Azure azure = AuthMethodManager .getInstance ().getAzureClient (subscrptionId );
46+ Azure azure = AuthMethodManager .getInstance ().getAzureClient (subscriptionId );
4347 ResourceGroup newResourceGroup = azure .resourceGroups ().define (config .getResourceGroup ().name ()).withRegion (config .getRegion ()).create ();
4448 config .setResourceGroup (newResourceGroup );
4549 }
@@ -48,13 +52,14 @@ public Server createMySQL(final AzureMySQLConfig config) {
4852 parameters .withAdministratorLogin (config .getAdminUsername ())
4953 .withAdministratorLoginPassword (String .valueOf (config .getPassword ()))
5054 .withVersion (config .getVersion ());
51- Server server = MySQLMvpModel .create (subscrptionId , config .getResourceGroup ().name (), config .getServerName (), config .getRegion (), parameters );
55+ Server server = MySQLMvpModel .create (subscriptionId , config .getResourceGroup ().name (), config .getServerName (), config .getRegion (), parameters );
5256 // update access from azure services
53- MySQLMvpModel .FirewallRuleMvpModel .updateAllowAccessFromAzureServices (subscrptionId , server , config .isAllowAccessFromAzureServices ());
57+ MySQLMvpModel .FirewallRuleMvpModel .updateAllowAccessFromAzureServices (subscriptionId , server , config .isAllowAccessFromAzureServices ());
5458 // update access from local machine
55- MySQLMvpModel .FirewallRuleMvpModel .updateAllowAccessToLocalMachine (subscrptionId , server , config .isAllowAccessFromLocalMachine ());
59+ MySQLMvpModel .FirewallRuleMvpModel .updateAllowAccessToLocalMachine (subscriptionId , server , config .isAllowAccessFromLocalMachine ());
5660 return server ;
5761 } catch (final RuntimeException e ) {
62+ EventUtil .logError (operation , ErrorType .systemError , e , null , null );
5863 throw e ;
5964 } finally {
6065 operation .complete ();
0 commit comments