swagger: "2.0"
schemes:
  - https
host: management.azure.com
info:
  description: The Azure SQL Database management API provides a RESTful set of web APIs that interact with Azure SQL Database services to manage your databases. The API enables users to create, retrieve, update, and delete databases, servers, and other entities.
  title: SqlManagementClient
  version: 2015-05-01-preview
  x-apisguru-categories:
    - cloud
  x-logo:
    url: https://api.apis.guru/v2/cache/logo/https_assets.onestore.ms_cdnfiles_onestorerolling-1606-01000_shell_v3_images_logo_microsoft.png
  x-origin:
    - format: swagger
      url: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/sql/resource-manager/Microsoft.Sql/preview/2015-05-01-preview/blobAuditingPolicies.json
      version: "2.0"
  x-providerName: azure.com
  x-serviceName: sql-blobAuditingPolicies
  x-tags:
    - Azure
    - Microsoft
consumes:
  - application/json
produces:
  - application/json
securityDefinitions:
  azure_auth:
    authorizationUrl: https://login.microsoftonline.com/common/oauth2/authorize
    description: Azure Active Directory OAuth2 Flow
    flow: implicit
    scopes:
      user_impersonation: impersonate your user account
    type: oauth2
parameters:
  ApiVersionParameter:
    description: The API version to use for the request.
    in: query
    name: api-version
    required: true
    type: string
    x-ms-parameter-location: client
  DatabaseNameParameter:
    description: The name of the database.
    in: path
    name: databaseName
    required: true
    type: string
    x-ms-parameter-location: method
  ResourceGroupParameter:
    description: The name of the resource group that contains the resource. You can obtain this value from the Azure Resource Manager API or the portal.
    in: path
    name: resourceGroupName
    required: true
    type: string
    x-ms-parameter-location: method
  ServerNameParameter:
    description: The name of the server.
    in: path
    name: serverName
    required: true
    type: string
    x-ms-parameter-location: method
  SubscriptionIdParameter:
    description: The subscription ID that identifies an Azure subscription.
    in: path
    name: subscriptionId
    required: true
    type: string
    x-ms-parameter-location: client
paths:
  "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/auditingSettings/{blobAuditingPolicyName}":
    get:
      description: Gets a database's blob auditing policy.
      operationId: DatabaseBlobAuditingPolicies_Get
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - description: The name of the database for which the blob audit policy is defined.
          in: path
          name: databaseName
          required: true
          type: string
        - description: The name of the blob auditing policy.
          enum:
            - default
          in: path
          name: blobAuditingPolicyName
          required: true
          type: string
          x-ms-enum:
            modelAsString: true
            name: BlobAuditingPolicyName
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully retrieved the database blob auditing policy.
          schema:
            $ref: "#/definitions/DatabaseBlobAuditingPolicy"
        default:
          description: |-
            *** Error Responses: ***

             * 400 BlobAuditingIsNotSupportedOnResourceType - Blob Auditing is currently not supported for this resource type.

             * 400 InvalidDatabaseBlobAuditingPolicyCreateRequest - The create database blob auditing policy request does not exist or has no properties object.

             * 400 InvalidBlobAuditActionsAndGroups - Invalid audit actions or action groups.

             * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.

             * 404 SourceDatabaseNotFound - The source database does not exist.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 500 DatabaseIsUnavailable - Loading failed. Please try again later.

             * 500 GetBlobAuditingPolicyFailed - Failed to get Auditing settings
      tags:
        - BlobAuditing
      x-ms-examples:
        Get a database's blob auditing policy:
          parameters:
            api-version: 2015-05-01-preview
            blobAuditingPolicyName: default
            databaseName: testdb
            resourceGroupName: blobauditingtest-6852
            serverName: blobauditingtest-2080
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/blobauditingtest-6852/providers/Microsoft.Sql/servers/blobauditingtest-2080/databases/testdb
                kind: V12
                name: default
                properties:
                  auditActionsAndGroups: []
                  isAzureMonitorTargetEnabled: false
                  isStorageSecondaryKeyInUse: false
                  retentionDays: 0
                  state: Disabled
                  storageAccountSubscriptionId: 00000000-0000-0000-0000-000000000000
                  storageEndpoint: ""
                type: Microsoft.Sql/servers/databases/auditingSettings
    put:
      description: Creates or updates a database's blob auditing policy.
      operationId: DatabaseBlobAuditingPolicies_CreateOrUpdate
      parameters:
        - $ref: "#/parameters/ResourceGroupParameter"
        - $ref: "#/parameters/ServerNameParameter"
        - description: The name of the database for which the blob auditing policy will be defined.
          in: path
          name: databaseName
          required: true
          type: string
        - description: The name of the blob auditing policy.
          enum:
            - default
          in: path
          name: blobAuditingPolicyName
          required: true
          type: string
          x-ms-enum:
            modelAsString: true
            name: BlobAuditingPolicyName
        - description: The database blob auditing policy.
          in: body
          name: parameters
          required: true
          schema:
            $ref: "#/definitions/DatabaseBlobAuditingPolicy"
        - $ref: "#/parameters/SubscriptionIdParameter"
        - $ref: "#/parameters/ApiVersionParameter"
      responses:
        "200":
          description: Successfully set the database blob auditing policy.
          schema:
            $ref: "#/definitions/DatabaseBlobAuditingPolicy"
        "201":
          description: Successfully created the database blob auditing policy.
          schema:
            $ref: "#/definitions/DatabaseBlobAuditingPolicy"
        default:
          description: |-
            *** Error Responses: ***

             * 400 BlobAuditingIsNotSupportedOnResourceType - Blob Auditing is currently not supported for this resource type.

             * 400 InvalidDatabaseBlobAuditingPolicyCreateRequest - The create database blob auditing policy request does not exist or has no properties object.

             * 400 InvalidBlobAuditActionsAndGroups - Invalid audit actions or action groups.

             * 400 DataSecurityInvalidUserSuppliedParameter - An invalid parameter value was provided by the client.

             * 404 SourceDatabaseNotFound - The source database does not exist.

             * 404 SubscriptionDoesNotHaveServer - The requested server was not found

             * 500 DatabaseIsUnavailable - Loading failed. Please try again later.

             * 500 UpsertBlobAuditingPolicyFailed - An error has occurred while saving Auditing settings, please try again later
      tags:
        - BlobAuditing
      x-ms-examples:
        Create or update a database's blob auditing policy with all parameters:
          parameters:
            api-version: 2015-05-01-preview
            blobAuditingPolicyName: default
            databaseName: testdb
            parameters:
              properties:
                auditActionsAndGroups:
                  - DATABASE_LOGOUT_GROUP
                  - DATABASE_ROLE_MEMBER_CHANGE_GROUP
                  - UPDATE on database::TestDatabaseName by public
                isAzureMonitorTargetEnabled: true
                isStorageSecondaryKeyInUse: false
                queueDelayMs: 4000
                retentionDays: 6
                state: Enabled
                storageAccountAccessKey: sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==
                storageAccountSubscriptionId: 00000000-1234-0000-5678-000000000000
                storageEndpoint: https://mystorage.blob.core.windows.net
            resourceGroupName: blobauditingtest-4799
            serverName: blobauditingtest-6440
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/blobauditingtest-4799/providers/Microsoft.Sql/servers/blobauditingtest-6440/databases/testdb
                kind: V12
                name: default
                properties:
                  auditActionsAndGroups:
                    - DATABASE_LOGOUT_GROUP
                    - DATABASE_ROLE_MEMBER_CHANGE_GROUP
                    - UPDATE on database::TestDatabaseName by public
                  isAzureMonitorTargetEnabled: true
                  isStorageSecondaryKeyInUse: false
                  queueDelayMs: 4000
                  retentionDays: 0
                  state: Enabled
                  storageAccountSubscriptionId: 00000000-1234-0000-5678-000000000000
                  storageEndpoint: https://mystorage.blob.core.windows.net
                type: Microsoft.Sql/servers/databases/auditingSettings
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/blobauditingtest-4799/providers/Microsoft.Sql/servers/blobauditingtest-6440/databases/testdb
                kind: V12
                name: default
                properties:
                  auditActionsAndGroups:
                    - DATABASE_LOGOUT_GROUP
                    - DATABASE_ROLE_MEMBER_CHANGE_GROUP
                    - UPDATE on database::TestDatabaseName by public
                  isAzureMonitorTargetEnabled: true
                  isStorageSecondaryKeyInUse: false
                  queueDelayMs: 4000
                  retentionDays: 0
                  state: Enabled
                  storageAccountSubscriptionId: 00000000-1234-0000-5678-000000000000
                  storageEndpoint: https://mystorage.blob.core.windows.net
                type: Microsoft.Sql/servers/databases/auditingSettings
        Create or update a database's blob auditing policy with minimal parameters:
          parameters:
            api-version: 2015-05-01-preview
            blobAuditingPolicyName: default
            databaseName: testdb
            parameters:
              properties:
                state: Enabled
                storageAccountAccessKey: sdlfkjabc+sdlfkjsdlkfsjdfLDKFTERLKFDFKLjsdfksjdflsdkfD2342309432849328476458/3RSD==
                storageEndpoint: https://mystorage.blob.core.windows.net
            resourceGroupName: blobauditingtest-4799
            serverName: blobauditingtest-6440
            subscriptionId: 00000000-1111-2222-3333-444444444444
          responses:
            "200":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/blobauditingtest-4799/providers/Microsoft.Sql/servers/blobauditingtest-6440/databases/testdb
                kind: V12
                name: default
                properties:
                  auditActionsAndGroups:
                    - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP
                    - FAILED_DATABASE_AUTHENTICATION_GROUP
                    - BATCH_COMPLETED_GROUP
                  isAzureMonitorTargetEnabled: false
                  isStorageSecondaryKeyInUse: false
                  retentionDays: 0
                  state: Enabled
                  storageAccountSubscriptionId: 00000000-0000-0000-0000-000000000000
                  storageEndpoint: https://mystorage.blob.core.windows.net
                type: Microsoft.Sql/servers/databases/auditingSettings
            "201":
              body:
                id: /subscriptions/00000000-1111-2222-3333-444444444444/resourceGroups/blobauditingtest-4799/providers/Microsoft.Sql/servers/blobauditingtest-6440/databases/testdb
                kind: V12
                name: default
                properties:
                  auditActionsAndGroups:
                    - SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP
                    - FAILED_DATABASE_AUTHENTICATION_GROUP
                    - BATCH_COMPLETED_GROUP
                  isAzureMonitorTargetEnabled: false
                  isStorageSecondaryKeyInUse: false
                  retentionDays: 0
                  state: Enabled
                  storageAccountSubscriptionId: 00000000-0000-0000-0000-000000000000
                  storageEndpoint: https://mystorage.blob.core.windows.net
                type: Microsoft.Sql/servers/databases/auditingSettings
definitions:
  DatabaseBlobAuditingPolicy:
    allOf:
      - allOf:
          - description: ARM resource.
            properties:
              id:
                description: Resource ID.
                readOnly: true
                type: string
              name:
                description: Resource name.
                readOnly: true
                type: string
              type:
                description: Resource type.
                readOnly: true
                type: string
            type: object
            x-ms-azure-resource: true
        description: ARM proxy resource.
        properties: {}
        type: object
    description: A database blob auditing policy.
    properties:
      kind:
        description: Resource kind.
        readOnly: true
        type: string
      properties:
        $ref: "#/definitions/DatabaseBlobAuditingPolicyProperties"
        description: Resource properties.
        x-ms-client-flatten: true
    type: object
  DatabaseBlobAuditingPolicyProperties:
    description: Properties of a database blob auditing policy.
    properties:
      auditActionsAndGroups:
        description: Specifies the Actions and Actions-Groups to audit.
        items:
          type: string
        type: array
      isStorageSecondaryKeyInUse:
        description: Specifies whether storageAccountAccessKey value is the storage’s secondary key.
        type: boolean
      retentionDays:
        description: Specifies the number of days to keep in the audit logs.
        format: int32
        type: integer
      state:
        description: Specifies the state of the policy. If state is Enabled, storageEndpoint and storageAccountAccessKey are required.
        enum:
          - Enabled
          - Disabled
        type: string
        x-ms-enum:
          modelAsString: false
          name: BlobAuditingPolicyState
      storageAccountAccessKey:
        description: Specifies the identifier key of the auditing storage account. If state is Enabled, storageAccountAccessKey is required.
        type: string
        x-ms-mutability:
          - create
          - update
      storageAccountSubscriptionId:
        description: Specifies the blob storage subscription Id.
        format: uuid
        type: string
      storageEndpoint:
        description: Specifies the blob storage endpoint (e.g. https://MyAccount.blob.core.windows.net). If state is Enabled, storageEndpoint is required.
        type: string
    required:
      - state
    type: object
