Change IIS to: SLL Settings uncheck Require SSL and Client Certs : ignore.
Tuesday, April 29, 2025
Friday, February 21, 2025
Dev Blog: Exporting a Database with SqlPackage.exe and Creating Users in SSMS
A streamlined process to export a SQL database using SqlPackage.exe and tackle common issues such as orphaned users and certificate errors. I’ll also include a brief guide on how to create a user via SQL Server Management Studio (SSMS).
Exporting the Database with SqlPackage.exe
Prepare the Database:
Ensure that your database has all necessary data and that any users are correctly linked to their corresponding logins. If you have orphaned users (users without matching server logins), either remove them or create the corresponding logins.Use SqlPackage.exe: (Can be downloaded from microsoft or installed with dotnet.exe
Use the following command from a Command Prompt or PowerShell session to export your database to a BACPAC file.batchSqlPackage.exe /Action:Export /SourceConnectionString:"Server=YOUR_SERVER;Database=YOUR_DATABASE;Trusted_Connection=True;Encrypt=True;TrustServerCertificate=True;" /TargetFile:"E:\BackupSites\YOUR_DATABASE\YOUR_DATABASE.bacpac"Replace
YOUR_SERVER,YOUR_DATABASE, and the target path with your actual server name, database name, and desired file location.This example assumes Windows Authentication and includes parameters to trust the server certificat
Troubleshooting Common Issues
Orphaned Users:
If you encounter errors about orphaned users during export, verify that each user in the database is associated with a corresponding login.Solution: Either remove the orphaned users or create matching logins and link them using:
sql-- Create login if not exists IF NOT EXISTS (SELECT * FROM sys.server_principals WHERE name = 'UserName') BEGIN CREATE LOGIN [UserName] WITH PASSWORD = 'YourStrongPassword!' END USE YourDatabase; ALTER USER [UserName] WITH LOGIN = [UserName];
Certificate Issues:
If you see errors like "The certificate chain was issued by an authority that is not trusted," addTrustServerCertificate=True(or setEncrypt=Falseif encryption is not needed) in your connection string.
Creating a User via SQL Server Management Studio
Create a Login:
- Open SSMS and connect to your server.
- In Object Explorer, expand the Security folder.
- Right-click on Logins and select New Login...
- Enter a login name and select the appropriate authentication method (e.g., Windows Authentication or SQL Server Authentication).
- Click OK to create the login.
Map the Login to a Database User:
- Expand the newly created login under the Logins folder.
- Right-click on the login and choose Properties.
- In the User Mapping page, select the database you want the user to access.
- Check the Map checkbox and assign the necessary database role memberships.
- Click OK to complete the process.
Using these steps, you can ensure a smooth export process with SqlPackage.exe and properly manage user logins and mappings within SSMS.
Finally, to import the BACPAC file into Azure using SSMS, connect to your Azure SQL Database. In Object Explorer, right-click the Databases folder and choose Import Data-tier Application. The Import wizard will prompt you to select a local BACPAC file; browse to the file you created earlier. Specify a target database name and configure any additional settings such as service tier and performance level. Follow through the remaining steps of the wizard to complete the import process. Once finished, your Azure SQL Database will contain the imported schema and data from your original database.
This approach helps you manage potential issues during export—such as orphaned users and certificate errors—and provides a clear workflow for both exporting with SqlPackage.exe and importing into Azure via SSMS. Happy coding and troubleshooting!
Saturday, August 10, 2024
Monday, April 15, 2024
Update swagger
Right click projekt then ADD then REST API Client (Create new) or Connected Services (Manage existing)
Monday, January 15, 2024
Monday, September 18, 2023
Thursday, December 8, 2022
Monday, November 28, 2022
Escape Json in Html Razor
data-campaign-category="@Html.Raw(HttpUtility.JavaScriptStringEncode(Model.SetCampaignData()))">
string json = JsonConvert.SerializeObject(blackFridayCampaign, Formatting.None, new JsonSerializerSettings(){ StringEscapeHandling = StringEscapeHandling.EscapeHtml});
Monday, August 22, 2022
Tuesday, May 24, 2022
Window devenv path
- Close all Visual Studio Instances running in your machine. Also, make sure devenv.exe is not running in the Task Manager
- Delete the Component cache directory -%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\1x.0\ComponentModelCache
- Restart Visual Studio
- Open the temp folder in this location - %USERPROFILE%\AppData\Local\Temp
- Delete all the files in the temp folder
- %USERPROFILE%\AppData\Local\Microsoft\Team Foundation
- %USERPROFILE%\AppData\Local\Microsoft\VisualStudio
- %USERPROFILE%\AppData\Local\Microsoft\VSCommon
Thursday, May 12, 2022
Friday, May 6, 2022
Tuesday, April 12, 2022
Create https cert locally for IIS and others.
1. Use Choco install to install mkcert.
2. Add mkcert to your local root CAs.
3. In terminal run mkcert -install
This will generate a local certificate authority (CA). Your mkcert-generated local CA is only trusted locally, on your device.
Now we need to generate a certificate for your site, signed by mkcert.In your terminal, navigate to your site's root directory or whichever directory you'd like the certificates to be located at.
mkcert localhost
OR
mkcert mysite.example
For use on IIS use the format pkcs12.
mkcert -pkcs12 somedomain.net
NOTE: replace somedomain.net with the domain you will be using locally. You can specify multiple domains (space-delimited) and even wildcard subdomains via *.somedomain.net
The command above will create a somedomain.net.p12 file in the folder where you invoked the mkcert command. This file is a PKCS#12 certificate, which is what IIS requires.
Rename the .p12 file to .pfx
IIS expects imported PKCS#12 certificates to have a .pfx extension. Be sure to rename the generated .p12 certificate to .pfx
Now the cert needs to be imported in the MMC certificates store or whatever.
To be able to then be append the https cert binding in IIS.
Right click on the window and file to import.
select your cert.
It will require a password that is specified in the response from mkcert when creating it.
Fore info
https://web.dev/how-to-use-local-https/
OBS: Note when you add this cert to IIS use the "Rquire Server name Indication"
Web.Config - Make it more readable with outlinining
Turn on outlining on - EDIT - Outlining (CTRL-M + CTRL-L)
Then to unfold every section select everything and press:
CTRL+M+ CTRL + M
Tuesday, March 29, 2022
Friday, March 4, 2022
Monday, February 28, 2022
EPiServer - Scheduled Job not running on schedule reminders
- Check if jobs have hanged in "running state in db". See other blog article.
- Check if server time is actually what Episerver is using.
- Check that the scheduled user is using a account that has rights. (job runs as other user than manual).
- See if other jobs are running an blocking.
- Set: <episerver><applicationSettings enableScheduler="true"
Wednesday, January 26, 2022
NPM - Node - Troubleshooting
Got an ugly error that didn't give me much info at all.
Cannot convert undefined or null to object.
After alot of head ache i started checking each npm package one by one with the tool
npm-check. So useful. In the interactive mode i could just install each missing package since i had tried removing npm-modules folder.
somehow the package install of gulp-modulizr was not getting a package back it seems it should be spelled modulizr-gulp. i tried removing it and now it works.
normal install of win node doesn't seem to work ok with nvm either so...
Tuesday, November 23, 2021
Visual Studio - Remove Unused Configuration Profiles
Sunday, November 21, 2021
Powershell - Add Permanent Environment variable
PS C:\Users\donald> Set-ItemProperty -Path 'Registry::HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\Environment' -Name PATH -Value ($Old_Path += ';z:\Dropbox\prio\')
PS C:\Users\donald> Get-Item Env:Path|fl
