@@ -602,27 +602,10 @@ struct flb_azure_kusto *flb_azure_kusto_conf_create(struct flb_output_instance *
602602 return NULL ;
603603 }
604604
605- if (ctx -> managed_identity_id == NULL ) {
606- /* config: 'tenant_id' */
607- if (ctx -> tenant_id == NULL ) {
608- flb_plg_error (ctx -> ins , "property 'tenant_id' is not defined." );
609- flb_azure_kusto_conf_destroy (ctx );
610- return NULL ;
611- }
612-
613- /* config: 'client_id' */
614- if (ctx -> client_id == NULL ) {
615- flb_plg_error (ctx -> ins , "property 'client_id' is not defined" );
616- flb_azure_kusto_conf_destroy (ctx );
617- return NULL ;
618- }
619-
620- /* config: 'client_secret' */
621- if (ctx -> client_secret == NULL ) {
622- flb_plg_error (ctx -> ins , "property 'client_secret' is not defined" );
623- flb_azure_kusto_conf_destroy (ctx );
624- return NULL ;
625- }
605+ if (ctx -> tenant_id == NULL && ctx -> client_id == NULL && ctx -> client_secret == NULL && ctx -> managed_identity_client_id == NULL ) {
606+ flb_plg_error (ctx -> ins , "Service Principal or Managed Identity is not defined" );
607+ flb_azure_kusto_conf_destroy (ctx );
608+ return NULL ;
626609 }
627610
628611 /* config: 'ingestion_endpoint' */
@@ -646,20 +629,58 @@ struct flb_azure_kusto *flb_azure_kusto_conf_create(struct flb_output_instance *
646629 return NULL ;
647630 }
648631
649- if (ctx -> managed_identity_id != NULL ) {
650- ctx -> oauth_url = flb_sds_create_size (sizeof (FLB_AZURE_MSIAUTH_URL_TEMPLATE ) - 1 +
651- flb_sds_len (ctx -> managed_identity_id ));
632+ if (ctx -> managed_identity_client_id != NULL ) {
633+ /* system assigned managed identity */
634+ if (strcasecmp (ctx -> managed_identity_client_id , "system" ) == 0 ) {
635+ ctx -> oauth_url = flb_sds_create_size (sizeof (FLB_AZURE_MSIAUTH_URL_TEMPLATE ) - 1 );
652636
653- if (!ctx -> oauth_url ) {
654- flb_errno ();
637+ if (!ctx -> oauth_url ) {
638+ flb_errno ();
639+ flb_azure_kusto_conf_destroy (ctx );
640+ return NULL ;
641+ }
642+
643+ flb_sds_snprintf (& ctx -> oauth_url , flb_sds_alloc (ctx -> oauth_url ),
644+ FLB_AZURE_MSIAUTH_URL_TEMPLATE , "" );
645+
646+ } else {
647+ /* user assigned managed identity */
648+ ctx -> oauth_url = flb_sds_create_size (sizeof (FLB_AZURE_MSIAUTH_URL_TEMPLATE ) - 1 +
649+ sizeof ("&client_id=" ) - 1 +
650+ flb_sds_len (ctx -> managed_identity_client_id ));
651+
652+ if (!ctx -> oauth_url ) {
653+ flb_errno ();
654+ flb_azure_kusto_conf_destroy (ctx );
655+ return NULL ;
656+ }
657+
658+ flb_sds_snprintf (& ctx -> oauth_url , flb_sds_alloc (ctx -> oauth_url ),
659+ FLB_AZURE_MSIAUTH_URL_TEMPLATE , ctx -> managed_identity_client_id );
660+ }
661+ }
662+ else {
663+ /* config: 'tenant_id' */
664+ if (ctx -> tenant_id == NULL ) {
665+ flb_plg_error (ctx -> ins , "property 'tenant_id' is not defined." );
666+ flb_azure_kusto_conf_destroy (ctx );
667+ return NULL ;
668+ }
669+
670+ /* config: 'client_id' */
671+ if (ctx -> client_id == NULL ) {
672+ flb_plg_error (ctx -> ins , "property 'client_id' is not defined" );
673+ flb_azure_kusto_conf_destroy (ctx );
674+ return NULL ;
675+ }
676+
677+ /* config: 'client_secret' */
678+ if (ctx -> client_secret == NULL ) {
679+ flb_plg_error (ctx -> ins , "property 'client_secret' is not defined" );
655680 flb_azure_kusto_conf_destroy (ctx );
656681 return NULL ;
657682 }
658683
659- flb_sds_snprintf (& ctx -> oauth_url , flb_sds_alloc (ctx -> oauth_url ),
660- FLB_AZURE_MSIAUTH_URL_TEMPLATE , ctx -> managed_identity_id );
661- }
662- else {
663684 /* Create the auth URL */
664685 ctx -> oauth_url = flb_sds_create_size (sizeof (FLB_MSAL_AUTH_URL_TEMPLATE ) - 1 +
665686 flb_sds_len (ctx -> tenant_id ));
0 commit comments