I am looking for deploy an angular website to an Azure static website.
Unfortunately i am running under Azure DevOps Server (so on-premises) and there is no task to deploy to static website (but it is possible with Azure DevOps Services).
So basically i try to find powershell command which take as input an output artificat (a zip file) and deploy to static website.
Usually i used command Publish-AzWebApp but this one supports only Azure appservice and not Azure static website.
How can you achieve this ?
Regards
For Creating New or Publishing the existing Static Site to Static Web Apps, it's the same command used in Azure PowerShell.
New-AzStaticWebApp - This command creates a new static site or updates an existing static side in an existing resource group.
While creating the Static Web App or Publishing in Azure, you will use the GitHub RepositoryUrl and Repository token for continuous deployment.
Azure PowerShell Syntax of Creating or Publishing the Static Web App:
New-AzStaticWebApp -ResourceGroupName 'azure-rg-test' -Name 'staticweb-45asde' -Location 'Central US' -RepositoryUrl 'https://github.com/LucasYao93/blazor-starter' -RepositoryToken 'githubAccessToken' -Branch 'branch02' -AppLocation 'Client' -ApiLocation 'Api' -OutputLocation 'wwwroot' -SkuName 'Standard'
Refer to this Microsoft Doc - PowerShell Modules of Static web app for more information.
Related
I've been trying to get the File System Endpoint to work for a migration I'm working on and so far have been unsuccessful getting the configuration to work right.
Situation: We have a Azure DevOps Service instance that contains our work items and we are now directed to migrate these work items to an instance of Azure DevOps Server that is in an "airgapped" environment. So the plan is to export the workitems via the FileSystemEndpoint and then run the reverse on the private environment.
My ask is has anyone used the FileSystemEndpoint for either export or import outside of the Tests?
I want to setup a .NET Core web application on Cloud Run with a Google Cloud SQL database. I easily deployed the database which has a public IP on Cloud SQL and my web application with Docker Container on Cloud Run. I can access the database with SQL Server Management Studio without any difficulties and the web app is up and running as expected. The only piece missing is the link between them that allows them to connect.
In my web app, I got a connection string in that format :
Data Source=***;Initial Catalog=***;User ID=***;Password=***;Pooling=true;Trusted_Connection=false;Connection Timeout=60;Integrated Security=false;Persist Security Info={0};Encrypt=true;TrustServerCertificate=true;MultipleActiveResultSets=true;
Once I got the public IP and the connection name from Cloud SQL, how should be precisely be the connection string and/or the next steps?
Furthermore, in the connections tab under Cloud Run Service, I added the Cloud SQL connection. This is supposed to configure a Cloud SQL Proxy for me.
In order to connect to Cloud SQL from Cloud Run, you must follow this guide
You have already made some configurations in the Connections tab as stated in the Configuring Cloud Run section. You can check the guide for the Public IP since you configured your instance that way, to be sure that all steps were followed.
Briefly, the steps are:
Configure the service account for your service. Make sure that the service account has the appropriate Cloud SQL roles and permissions to connect to Cloud SQL.
The service account for your service needs one of the following IAM roles:
Cloud SQL Client (preferred)
Cloud SQL Admin
If the authorizing service account belongs to a different project than the Cloud SQL instance, the Cloud SQL Admin API and IAM permissions will need to be added for both projects.
Like any configuration change, setting a new configuration for the Cloud SQL connection leads to the creation of a new Cloud Run revision. Subsequent revisions will also automatically get this Cloud SQL connection, unless you make explicit updates to change it.
Go to Cloud Run
Configure the service:
If you are adding Cloud SQL connections to an existing service:
Click on the service name.
Click on the Connections tab.
Click Deploy.
Enable connecting to a Cloud SQL instance:
Click Advanced Settings.
Click on the Connections tab.
If you are adding a connection to a Cloud SQL instance in your project, select the desired Cloud SQL instance from the dropdown menu.
If you are deleting a connection, hover your cursor to the right of the connection to display the Trash icon, and click it.
Click Create or Deploy.
After you've double checked the steps above, you could continue with the section Connecting to Cloud SQL. You can follow the steps on the Public IP tab.
Connect with Unix sockets
Once correctly configured, you can connect your service to your Cloud SQL instance's Unix domain socket accessed on the environment's filesystem at the following path: /cloudsql/INSTANCE_CONNECTION_NAME.
The INSTANCE_CONNECTION_NAME can be found on the Overview page for your instance in the Google Cloud Console or by running the following command:
gcloud sql instances describe [INSTANCE_NAME].
These connections are automatically encrypted without any additional configuration.
The code samples shown below are extracts from more complete examples on the GitHub site. To see this snippet in the context of a web application, view the README on GitHub.
// Equivalent connection string:
// "Server=<dbSocketDir>/<INSTANCE_CONNECTION_NAME>;Uid=<DB_USER>;Pwd=<DB_PASS>;Database=<DB_NAME>;Protocol=unix"
String dbSocketDir = Environment.GetEnvironmentVariable("DB_SOCKET_PATH") ?? "/cloudsql";
String instanceConnectionName = Environment.GetEnvironmentVariable("INSTANCE_CONNECTION_NAME");
var connectionString = new MySqlConnectionStringBuilder()
{
// The Cloud SQL proxy provides encryption between the proxy and instance.
SslMode = MySqlSslMode.None,
// Remember - storing secrets in plain text is potentially unsafe. Consider using
// something like https://cloud.google.com/secret-manager/docs/overview to help keep
// secrets secret.
Server = String.Format("{0}/{1}", dbSocketDir, instanceConnectionName),
UserID = Environment.GetEnvironmentVariable("DB_USER"), // e.g. 'my-db-user
Password = Environment.GetEnvironmentVariable("DB_PASS"), // e.g. 'my-db-password'
Database = Environment.GetEnvironmentVariable("DB_NAME"), // e.g. 'my-database'
ConnectionProtocol = MySqlConnectionProtocol.UnixSocket
};
connectionString.Pooling = true;
// Specify additional properties here.
return connectionString;
Google recommends that you use Secret Manager to store sensitive information such as SQL credentials. You can pass secrets as environment variables or mount as a volume with Cloud Run.
After creating a secret in Secret Manager, update an existing service, with the following command:
gcloud run services update SERVICE_NAME \
--add-cloudsql-instances=INSTANCE_CONNECTION_NAME
--update-env-vars=INSTANCE_CONNECTION_NAME=INSTANCE_CONNECTION_NAME_SECRET \
--update-secrets=DB_USER=DB_USER_SECRET:latest \
--update-secrets=DB_PASS=DB_PASS_SECRET:latest \
--update-secrets=DB_NAME=DB_NAME_SECRET:latest
See also:
GoogleCloudPlatform/dotnet-docs-samples on GitHub
I'm trying to add an Azure storage account to my ASP.NET Core project (.NET Core 2.0 + VS2017) using Connected Services.
Following this tutorial, Visual Studio should list "Cloud Storage with Azure Storage" in Connected Services, but it doens't. The only item in the list is Application Insights.
I did some research and I read about installing Cloud Explorer for Visual Studio 2017 extension... unfortunately, without success, the only item still being Application Insights.
Is there any workaround or solution for this? If not, how can I connect my project to my Azure Storage account?
Based on my test, no matter net core 1.1 or 2.0, visual studio 2017 all doesn't support add the azure storage using Connected Services now.
The workaround is connecting to the azure storage account by yourself.
More details, you could refer to below steps:
1.Install the WindowsAzure.Storage from Nuget Package manager.
2.Find the connection string from azure portal.
Find the storage connection string
Directly use the connection string in the project.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
"yourconnectionstring");
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference("brandotest");
// Retrieve reference to a blob named "myblob".
CloudBlockBlob blockBlob = container.GetBlockBlobReference("myblob.txt");
// Create or overwrite the "myblob" blob with contents from a local file.
using (var fileStream = System.IO.File.OpenRead(#"D:\json2.txt"))
{
blockBlob.UploadFromStreamAsync(fileStream);
}
You could also set the connection string in the appsetting.json and inject to your codes. More details, you could refer to this article.
I am putting together a website which I would like to host static content via Azure Blob. The documentation is very clear on how to set "Public read access for blobs only" to a container via this document: https://learn.microsoft.com/en-us/azure/storage/storage-manage-access-to-resources
In my development environment I am using the Azure storage emulator (https://learn.microsoft.com/en-us/azure/storage/storage-use-emulator).
My question is: How can I set the permission of a container in the emulator to "Public read access for blobs only"?
I think I answered my own question. Unlike the Azure Portal the Emulator does not provide a mechanism to create a container and by extension set/modify the access policy. Using a third party tool such as CloudBerry Explorer will allow for the setting of the policy when a container is created. Additionally it is possible to set/modify the policy through code:
https://learn.microsoft.com/en-us/azure/storage/storage-manage-access-to-resources
public static void SetPublicContainerPermissions(CloudBlobContainer container)
{
BlobContainerPermissions permissions = container.GetPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Container;
container.SetPermissions(permissions);
}
I'm playing around with a small ASP.NET Core 1.1 app which I have published. Now I'm following the documentation with regards to using appsettings*.json and environment variables. So I have the following:
appsettings.json
appsettings.Development.json
Each appsettings*.json file has an appropriate "ConnectionStrings:" section:
"ConnectionStrings": {
"IdeasDatabase": "Server=tcp:adb.database.windows.net,1433;Initial Catalog=db;Persist Security Info=False;User ID=a_user;Password=apwd;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;"
}
So, when I published to begin with to Azure, I used a default connection string in the Publish settings (which was wrong I know), now this is showing in Azure remote settings for the my app:
The above connection string was populated on my first publish in this screen (Publish Wizard):
Now my Production app seems to be using this setting in the above image and not taking the setting from my appsettings.json connection string section.
My appsetting.json file is present on Azure App Service:
I know I can override that Database connection string in the Publish wizard tot the correct string, but shouldn't Azure take the Connection String first from my appsettings.json file which is different from wherever it is storing it on Azure.
now this is showing in Azure remote settings for the my app:
Azure remote settings stored as environment variables. It has a higher priority than configuration in appsettings.json. If you want to use the settings which configured in appsettings.json at runtime on Azure, you could delete the Azure remote settings from Azure portal or Visual Studio. After that, Azure Web App will use the setting in appsettings.json.
Use the environment variables or another secure mechanism. Storing the production connection string in a file is insecure.