Exemplo n.º 1
0
        /// <summary>
        /// Convert a Management.Sql.Models.ServerTrustCertificate to AzureSqlInstanceServerTrustCertificateModel
        /// </summary>
        /// <param name="serverTrustCertificate">The management client server trust certificate response to convert</param>
        /// <returns>The converted server trust certificate model</returns>
        private static AzureSqlInstanceServerTrustCertificateModel CreateServerTrustCertificateModelFromResponse(string resourceGroupName, string instanceName, Management.Sql.Models.ServerTrustCertificate serverTrustCertificate)
        {
            AzureSqlInstanceServerTrustCertificateModel serverTrustCertificateModel = new AzureSqlInstanceServerTrustCertificateModel()
            {
                ResourceGroupName = resourceGroupName,
                InstanceName      = instanceName,
                Id         = serverTrustCertificate.Id,
                Type       = serverTrustCertificate.Type,
                Name       = serverTrustCertificate.CertificateName,
                PublicKey  = "0x" + serverTrustCertificate.PublicBlob,
                Thumbprint = "0x" + serverTrustCertificate.Thumbprint
            };

            return(serverTrustCertificateModel);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Upserts a Server Trust Certificate to Azure SQL Managed Instance
        /// </summary>
        /// <param name="model">The input parameters for the create/update operation</param>
        /// <returns>The upserted Azure Sql Database ElasticPool</returns>
        internal AzureSqlInstanceServerTrustCertificateModel UpsertServerTrustCertificate(AzureSqlInstanceServerTrustCertificateModel model)
        {
            var resp = Communicator.CreateOrUpdate(model.ResourceGroupName, model.InstanceName, model.Name, new Management.Sql.Models.ServerTrustCertificate
            {
                PublicBlob = model.PublicKey,
            });

            return(CreateServerTrustCertificateModelFromResponse(model.ResourceGroupName, model.InstanceName, resp));
        }