///GENMHASH:637F0A3522F2C635C23E54FAAD79CBEA:FE111B80F10F1D62FBC7A570DF172CC4 public async Task <Microsoft.Azure.Management.Sql.Fluent.ISqlDatabaseImportExportResponse> ExecuteWorkAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (this.storageAccountCreatable != null) { this.storageAccount = await storageAccountCreatable.CreateAsync(cancellationToken) ?? throw new Exception("Failed to create Storage Account"); } if (this.storageAccount != null) { var storageKeys = (await storageAccount.GetKeysAsync(cancellationToken)); if (storageKeys == null || storageKeys.Count == 0) { throw new Exception("Failed to retrieve Storage Account Keys"); } var storageAccountKey = storageKeys[0].Value; this.Inner.StorageUri = $"{this.storageAccount.EndPoints.Primary.Blob}{this.containerName}/{this.fileName}"; this.Inner.StorageKeyType = StorageKeyType.StorageAccessKey; this.Inner.StorageKey = storageAccountKey; // Create the storage account container if one does not exist var sas = $"DefaultEndpointsProtocol=https;AccountName={storageAccount.Name};AccountKey={storageAccountKey};EndpointSuffix=core.Windows.Net"; var cloudBlobClient = CloudStorageAccount.Parse(sas).CreateCloudBlobClient(); await cloudBlobClient.GetContainerReference(containerName).CreateIfNotExistsAsync(); } var importExportResponseInner = await this.sqlServerManager.Inner.Databases .ExportAsync(this.sqlDatabase.ResourceGroupName(), this.sqlDatabase.SqlServerName(), this.sqlDatabase.Name(), this.Inner, cancellationToken); return(new SqlDatabaseImportExportResponseImpl(importExportResponseInner)); }
///GENMHASH:1F5324043331585B2120A5C89F84F5DB:0CFB327CCEC02962E7DF01BD3571BC6E public SqlDatabaseExportRequestImpl ExportTo(ICreatable <Microsoft.Azure.Management.Storage.Fluent.IStorageAccount> storageAccountCreatable, string containerName, string fileName) { this.storageAccountCreatable = storageAccountCreatable ?? throw new System.ArgumentNullException("storageAccountCreatable"); this.containerName = containerName ?? throw new System.ArgumentNullException("containerName"); this.fileName = fileName ?? throw new System.ArgumentNullException("fileName"); this.storageAccount = null; return(this); }
private static string CreateStaticWeb(string storageName, string rgName, string region, IAzure azureContext, ILogger log) { string connectionString = string.Empty; Microsoft.Azure.Management.Storage.Fluent.IStorageAccount storageAccount = azureContext.StorageAccounts.Define(storageName). WithRegion(region). WithExistingResourceGroup(rgName). WithGeneralPurposeAccountKindV2(). Create(); // Get connection keys IReadOnlyList <Microsoft.Azure.Management.Storage.Fluent.Models.StorageAccountKey> saKeys = storageAccount.GetKeys(); string key = string.Empty; foreach (Microsoft.Azure.Management.Storage.Fluent.Models.StorageAccountKey item in saKeys) { // Use the key1 if (item.KeyName.Equals(KEY1)) { key = item.Value; } } // need to set the storage properties to enable static web site connectionString = GetStorageConnectionString(key, storageName, log); BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString); BlobServiceProperties myProps = blobServiceClient.GetProperties(); myProps.StaticWebsite.Enabled = true; myProps.StaticWebsite.IndexDocument = "index.html"; myProps.StaticWebsite.ErrorDocument404Path = "error/index.html"; log.LogInformation(myProps.StaticWebsite.ToString()); blobServiceClient.SetProperties(myProps); log.LogInformation("DeployWeb: got static web enabled"); return(connectionString); }