I think a lot of other replies are missing the nuance.
It depends on a lot of things. Time of year, time of day, skin colour, where you live, if you're under an Ozone hole, UV index, personal sensitivity/medications, etc.
This is a good summary[0] for the situation in Australia, possibly the worst in the world when it comes to the sun being deadly. Their strongest statement about avoiding sun:
"During summer in Australia, all states experience long periods during the day when the UV Index is 3 or above (see Table 1). During these periods, a combination of sun protection measures (broad brimmed hat, covering clothing, sunscreen, sunglasses and shade) is recommended when outdoors for more than a few minutes. In summer, most Australian adults will maintain adequate vitamin D levels from sun exposure during typical day to day outdoor activities."
So a few minutes in the sun without protection is enough to raise your cancer risk during the worse times on the worst days and you shouldn't be seeking any sun intentionally for vitamin D during these times. Growing up it was easy to get sunburned in 10-15 minutes on some days, and the advice was that if you burn you definitely raised your cancer risk.
[0]: https://wiki.cancer.org.au/policy/Position_statement_-_Risks...