Description
From Customer Question - MicrosoftDocs/azure-docs-cli#2052
Is there a way to retrieve azure service principal password using azure sdk for python? I am creating service principal using following but service principal create response has empty password.
def create_azure_service_principal(self, app_name=None):
app = self.graphrbac_client.applications.create({
'available_to_other_tenants': False,
'display_name': app_name,
'identifier_uris': [f'http://{app_name}'],
'app_roles': []
})
sp = self.graphrbac_client.service_principals.create({
'app_id': app.app_id,
'account_enabled': True
})
return sp
Here is the response :
{
'additional_properties': {
'odata.type': 'Microsoft.DirectoryServices.ServicePrincipal',
'signInAudience': 'AzureADMyOrg',
'preferredSingleSignOnMode': None,
'preferredTokenSigningKeyEndDateTime': None,
'samlSingleSignOnSettings': None,
'applicationTemplateId': None,
'notificationEmailAddresses': [],
'addIns': [],
'tokenEncryptionKeyId': None,
'informationalUrls': {
'termsOfService': None,
'support': None,
'privacy': None,
'marketing': None
},
'odata.metadata': 'https://graph.windows.net/<tenant_id>/$metadata#directoryObjects/@element'
},
'object_id': '<object_id>',
'deletion_timestamp': None,
'object_type': 'ServicePrincipal',
'account_enabled': True,
'alternative_names': [],
'app_display_name': 'my-test',
'app_id': '<app_id>',
'app_owner_tenant_id': '<tenant_id>',
'app_role_assignment_required': False,
'app_roles': [],
'display_name': 'my-test',
'error_url': None,
'homepage': None,
'key_credentials': [],
'logout_url': None,
'oauth2_permissions': [ < azure.graphrbac.models.oauth2_permission_py3.OAuth2Permission object at 0x7f64567b67810 > ],
'password_credentials': [],
'preferred_token_signing_key_thumbprint': None,
'publisher_name': 'Default Directory',
'reply_urls': [],
'saml_metadata_url': None,
'service_principal_names': ['<app_id>'],
'service_principal_type': 'Application',
'tags': []
}
Is there a way to reset the service principal using python sdk?
Not : I know we can this using azure cli but not sure if i want to mix azure sdk and cli in my code.
Please advice...