Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,19 @@ def get_source_display_name(sourcename):
source_display_name=source_display_name
) if source is RESOURCE.KubernetesCluster and target is RESOURCE.KeyVault else ''

id_example = '''
- name: Create a connection between {source_display_name} and {target} with resource id
text: |-
az {source} connection create {target} --source-id {source_id} --target-id {target_id} {auth_params}
'''.format(
source=source.value,
target=target.value,
source_id=source_id,
target_id=target_id,
auth_params=auth_params,
source_display_name=source_display_name
) if target is not RESOURCE.NeonPostgres else ''

helps['{source} connection create {target}'.format(source=source.value, target=target.value)] = """
type: command
short-summary: Create a {source_display_name} connection to {target}.
Expand All @@ -409,15 +422,11 @@ def get_source_display_name(sourcename):
text: |-
az {source} connection create {target} {source_params} {target_params} {auth_params}
{webappslot_example}
- name: Create a connection between {source_display_name} and {target} with resource id
text: |-
az {source} connection create {target} --source-id {source_id} --target-id {target_id} {auth_params}
{id_example}
{provision_example}
""".format(
source=source.value,
target=target.value,
source_id=source_id,
target_id=target_id,
secret_param=secret_param,
secret_auto_param=secret_auto_param,
system_identity_param=system_identity_param,
Expand All @@ -429,6 +438,7 @@ def get_source_display_name(sourcename):
auth_params=auth_params,
provision_example=provision_example,
webappslot_example=webappslot_example,
id_example=id_example,
source_display_name=source_display_name)

helps['{source} connection update {target}'.format(source=source.value, target=target.value)] = """
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,12 @@ def add_target_resource_block(context, target):
context.argument(arg, options_list=content.get('options'), type=str,
help='{}. Required if \'--target-id\' is not specified.'.format(content.get('help')))
required_args.append(content.get('options')[0])

context.argument('target_id', type=str,
help='The resource id of target service. Required if {required_args} '
'are not specified.'.format(required_args=str(required_args)))
if target == RESOURCE.NeonPostgres:
context.ignore('target_id')
else:
context.argument('target_id', type=str,
help='The resource id of target service. Required if {required_args} '
'are not specified.'.format(required_args=str(required_args)))

if target != RESOURCE.KeyVault:
context.ignore('enable_csi')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class RESOURCE(Enum):
FabricSql = 'fabric-sql'
AppInsights = 'app-insights'
CognitiveServices = 'cognitiveservices'
NeonPostgres = 'neon-postgres'

@classmethod
def value_of(cls, value):
Expand Down Expand Up @@ -155,7 +156,9 @@ class CLIENT_TYPE(Enum):

RESOURCE.ContainerApp: '/subscriptions/{subscription}/resourceGroups/{target_resource_group}/providers/Microsoft.App/containerApps/{target_app_name}',

RESOURCE.FabricSql: 'https://api.fabric.microsoft.com/v1/workspaces/{fabric_workspace_uuid}/SqlDatabases/{fabric_sql_db_uuid}'
RESOURCE.FabricSql: 'https://api.fabric.microsoft.com/v1/workspaces/{fabric_workspace_uuid}/SqlDatabases/{fabric_sql_db_uuid}',
RESOURCE.NeonPostgres: '/subscriptions/aaaabbbb-0000-cccc-1111-dddd2222eeee/resourceGroups/testrg/providers/Neon.Postgres/organizations/neontest'

}


Expand Down Expand Up @@ -679,6 +682,19 @@ class CLIENT_TYPE(Enum):
'options': ['--fabric-sql-db-uuid'],
'help': 'UUID of the target Fabric SQL database',
'placeholder': 'TargetFabricSQLDatabaseUUID'
},
},
RESOURCE.NeonPostgres: {
'server': {
'configured_default': 'sql-server',
'options': ['--server'],
'help': 'Name of the sql server',
'placeholder': 'MyServer'
},
'database': {
'options': ['--database'],
'help': 'Name of the sql database',
'placeholder': 'MyDB'
}
}
}
Expand Down Expand Up @@ -845,7 +861,8 @@ class CLIENT_TYPE(Enum):
RESOURCE.FabricSql: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity],
RESOURCE.AppInsights: [AUTH_TYPE.SecretAuto],

RESOURCE.CognitiveServices: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret]
RESOURCE.CognitiveServices: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.NeonPostgres: [AUTH_TYPE.Secret]
},
RESOURCE.SpringCloud: {
RESOURCE.Postgres: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
Expand Down Expand Up @@ -877,7 +894,8 @@ class CLIENT_TYPE(Enum):
RESOURCE.FabricSql: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity],
RESOURCE.AppInsights: [AUTH_TYPE.SecretAuto],

RESOURCE.CognitiveServices: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret]
RESOURCE.CognitiveServices: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.NeonPostgres: [AUTH_TYPE.Secret]
},
RESOURCE.KubernetesCluster: {
RESOURCE.Postgres: [AUTH_TYPE.Secret],
Expand Down Expand Up @@ -908,7 +926,8 @@ class CLIENT_TYPE(Enum):
RESOURCE.ConfluentKafka: [AUTH_TYPE.Secret],
RESOURCE.AppInsights: [AUTH_TYPE.SecretAuto],

RESOURCE.CognitiveServices: [AUTH_TYPE.WorkloadIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret]
RESOURCE.CognitiveServices: [AUTH_TYPE.WorkloadIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.NeonPostgres: [AUTH_TYPE.Secret]
},
RESOURCE.ContainerApp: {
RESOURCE.Postgres: [AUTH_TYPE.Secret, AUTH_TYPE.SystemIdentity, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
Expand Down Expand Up @@ -941,6 +960,7 @@ class CLIENT_TYPE(Enum):
RESOURCE.AppInsights: [AUTH_TYPE.SecretAuto],

RESOURCE.CognitiveServices: [AUTH_TYPE.SystemIdentity, AUTH_TYPE.SecretAuto, AUTH_TYPE.UserIdentity, AUTH_TYPE.ServicePrincipalSecret],
RESOURCE.NeonPostgres: [AUTH_TYPE.Secret],

RESOURCE.ContainerApp: [AUTH_TYPE.Null]
},
Expand Down Expand Up @@ -979,6 +999,19 @@ class CLIENT_TYPE(Enum):
CLIENT_TYPE.SpringBoot,
CLIENT_TYPE.Blank
],
RESOURCE.NeonPostgres: [
CLIENT_TYPE.Dotnet,
CLIENT_TYPE.DotnetInternal,
CLIENT_TYPE.Java,
CLIENT_TYPE.Python,
CLIENT_TYPE.Nodejs,
CLIENT_TYPE.Go,
CLIENT_TYPE.Php,
CLIENT_TYPE.Ruby,
CLIENT_TYPE.Django,
CLIENT_TYPE.SpringBoot,
CLIENT_TYPE.Blank
],
RESOURCE.Mysql: [
CLIENT_TYPE.Dotnet,
CLIENT_TYPE.DotnetInternal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ def connection_create(cmd, client, # pylint: disable=too-many-locals,too-many-s
opt_out_list=opt_out_list,
app_config_id=app_config_id,
enable_appconfig_extension=enable_appconfig_extension,
server=server, database=database,
connstr_props=connstr_props
)

Expand Down Expand Up @@ -442,6 +443,12 @@ def connection_create_func(cmd, client, # pylint: disable=too-many-locals,too-m
"id": target_id
}

if target_type == RESOURCE.NeonPostgres:
if connstr_props is None:
connstr_props = {}
connstr_props['Database'] = database
connstr_props['Server'] = server

parameters = {
'target_service': targetService,
'auth_info': auth_info,
Expand Down
Loading